Hi,
To send a file in a multipart request, you have to use com.HTTPPart.CreateAttachment() if it is not the main part, and use one of the doXXXRequest() methods for the main part.
But in your case, you have only one part, so it must be handled as the main part via the doDataRequest() method, and notify the API to perform multipart anyway with the com.HTTPRequest.setMultipart() method.
This gives something like following :
IMPORT COM
CONSTANT SERVER_URL = "
http://host:port/XXX"
CONSTANT FILE_NAME = "my_filename.jpg"
MAIN
DEFINE req com.HTTPRequest
DEFINE resp com.HTTPResponse
DEFINE blob BYTE
# Create Request
LET req = com.HTTPRequest.Create(SERVER_URL)
CALL req.setMethod("POST")
# Switch to multipart
CALL req.setMultipartType("mixed",NULL,NULL)
# Load main part as a blob
LOCATE blob IN MEMORY
CALL blob.readFile(FILE_NAME)
# Set right content-type
CALL req.setHeader("Content-Type","image/jpg")
# Perform request
CALL req.doDataRequest(blob)
# Process response
LET resp = req.getResponse()
DISPLAY "HTTPStatus : ",resp.getStatusCode()
END MAIN
Does this help ?
Frank