 Archived Forum Post
 Archived Forum PostQuestion:
I am adding 2 different files to a MIME for a upload over HTTP This is what I have in my code:
Dim http As New ChilkatHttp
Dim req As ChilkatHttpRequest
'  Adding the Connection: Keep-Alive is optional.  It only makes sense if the intent is to send
        '  additional requests to the same domain (your-namespace-sb.accesscontrol.windows.net) within a reasonable time period.
            req.AddHeader "X-EBAY-SOA-SERVICE-NAME", "FileTransferService"
            req.AddHeader "X-EBAY-SOA-OPERATION-NAME", APICALL
            req.AddHeader "X-EBAY-SOA-SECURITY-TOKEN", TokenValue
            req.AddHeader "X-EBAY-API-COMPATIBILITY-LEVEL", "967"
            req.AddHeader "X-EBAY-SOA-REQUEST-DATA-FORMAT", "XML"
            req.AddHeader "X-EBAY-SOA-RESPONSE-DATA-FORMAT", "XML"
        '  --------------------------------------------------
        '  IMPORTANT: Never set the Content-Length header.
        '  Chilkat will automatically compute the correct Content-Length and will add it.
        '  --------------------------------------------------
        '  Add the params to the request.  Given that the Content-Type is set to "multipart/form-data", when
        '  Chilkat composes the request, it will put each param in it's own MIME sub-part (i.e. in it's own
        '  part delimited by the boundary string).
        'req.AddParam "UploadAgent", "InterfaceVersion1.5"
        'req.AddParam "user", "XXX"
        'req.AddParam "password", "XXX"
        'req.AddParam "file", "XXX"
        'req.AddParam "data_version", "XXX"
        'req.AddParam "Content-ID", "<0.urn:uuid:" & XMLUUID & ">"
        Dim pathToFileOnDisk1 As String
        pathToFileOnDisk1 = "C:\Users\Station\Documents\Access XML Save Files\New Testing\uploadFile.xml"
        success = req.AddFileForUpload("uploadFile.xml", pathToFileOnDisk1)
        If (success <> 1) Then
            Debug.Print req.LastErrorText
            Exit Function
        End If
        '  The last param is the contents of a file.
        '  If it's a file on disk, we can add it like this:
        Dim pathToFileOnDisk2 As String
        pathToFileOnDisk2 = "C:\Users\Station\Documents\Access XML Save Files\New Testing\AFPIBulkTest1.gz"
        success = req.AddFileForUpload("AFPIBulkTest1.gz", pathToFileOnDisk2)
        If (success <> 1) Then
            Debug.Print req.LastErrorText
            Exit Function
        End If
This is what I get:
--------------060408050104030508030006
    Content-Disposition: form-data; name="AFPIBulkTest1.gz"; filename="AFPIBulkTest1.gz"
    Content-Type: application/x-gzip
    ‹ÌÝìX AFPIBulkTest1.xml ½Y_oÓ0Gâ;X}@ A“m°uý3`b…²n ñ‚ÜøÚR»Ø,|zÎIÚ´qZHëCeû~wþÙ>Ÿ
But this is what I need:
--MIMEBoundaryurn_uuid_C0FC77A812E40EAE841226969745133
Content-Disposition: form-data; name="fieldNameHere"; filename="AFPIBulkTest1.gz"
Content-Type: application/x-gzip
Content-Transfer-Encoding: binary
 Content-ID: <urn:uuid:5b23fffc-214d-11e7-93ae-92361f002671>
How do I add the Content-ID Header for the single Attachment? VBA in Access. Thanks
You would call HttpRequest.AddSubHeader(index,"Content-ID","<urn:uuid:5b23fffc-214d-11e7-93ae-92361f002671>"), where the 1st arg is the index of the sub-part (0 would be the index of the 1st MIME sub-part).