login about faq

I am currently trying to create a webrequest that matches a third party's example. I have found that the ActiveX HTTP object will create a request where addheader will add HTTP headers and addparam will add HTTP(or MIME) parameters. I am not sure if I am missing something in the Chilkat reference materials or not. When I test the request, I get a HTTP 500 error back from the third party's server. The third party's example has Content-Type and Content-Transfer-Encoding on each of its parameters. Also, this could play a role because one of the parameters is a file sent in binary. The rest of the parameters are plain text. The third party also puts the host name in the POST line and adds an additional value to the Content-Disposition element that states the file name being uploaded. I'm not sure how to have Chilkat HTTP to do any of that. I am using Visual FoxPro 9.0 and the ActiveX Chilkat component (The new 9.5.0 single dll).

Here is the request I am sending (values changed to protect data of course) per the Chilkat log:

POST /Putting/Files/In/APathSomewhere.html HTTP/1.1 
Content-Type: multipart/form-data; boundary=------------060900060309090107080400 
Accept: application/zip 
Accept-Language: en-us 
Cookie: SMCHALLENGE=YES 
Authorization: Basic AAAAAAAAAAAAAAAAAAAAAAAAAA= 
Host: test.somewebsite.com 
Content-Length: 43839

--------------060900060309090107080400 
Content-Disposition: form-data; name="Variable1"

Variable1Value
--------------060900060309090107080400 
Content-Disposition: form-data; name="Variable2"

Variable2Value
--------------060900060309090107080400 
Content-Disposition: form-data; name="Variable3"

Variable3Value
--------------060900060309090107080400
Content-Disposition: form-data; name="UploadFile"

BinaryFileCharactersHere

Here is what the third party is saying a valid example is:

POST https://test.somewebsite.com/Putting/Files/In/APathSomewhere.html HTTP/1.1 
Content-Type: multipart/form-data; boundary="------------060900060309090107080400"
Accept: application/zip 
Accept-Language: en-us 
Cookie: SMCHALLENGE=YES 
Authorization: Basic AAAAAAAAAAAAAAAAAAAAAAAAAA= 
Content-Length: 43839

--------------060900060309090107080400 
Content-Disposition: form-data; name="Variable1"
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Variable1Value
--------------060900060309090107080400 
Content-Disposition: form-data; name="Variable2"
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Variable2Value
--------------060900060309090107080400 
Content-Disposition: form-data; name="Variable3"
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Variable3Value
--------------060900060309090107080400 
Content-Type: application/zip; name=SomeFile.xml.gz
Content-Transfer-Encoding: binary
Content-Disposition: form-data; name="UploadFile"; filename="SomeFile.xml.gz"

BinaryFileCharactersHere

asked Sep 04 '14 at 17:04

Bob%20Cork's gravatar image

Bob Cork
612


If the data in the HttpRequest object is added as parameters (via the HttpRequest.AddParam method), then you'll get what you are currently sending:

...
 --------------060900060309090107080400 
 Content-Disposition: form-data; name="Variable1" 

Variable1Value --------------060900060309090107080400 Content-Disposition: form-data; name="Variable2"

Variable2Value ...

If you add the data as "files" to be uploaded, then you'll produce an HTTP request with the additional headers. Instead of calling AddParam, call the AddBytesForUpload2 method for binary data, and AddStringForUpload2 method for text data. These methods allow for you to explicitly specify the content-type.

link

answered Sep 05 '14 at 08:56

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

edited Sep 05 '14 at 08:56

Sorry for the late reply. That worked, Thanks! For anyone else who wants to use the AddBytesForUpload2 method with ActiveX and Visual FoxPro 9, I needed to use the chilkat FileAccess object's ReadEntireFile method to pull a varbinary structure that I could then pass to the AddBytesForUpload2 method. Passing FILETOSTR of the file resulted in what looked like a Unicode version of the file in binary. There is probably some other way to do it in VFP, but it's working with chilkat.

(Sep 11 '14 at 17:29) Bob Cork
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×35
×29
×4

Asked: Sep 04 '14 at 17:04

Seen: 1,423 times

Last updated: Sep 11 '14 at 17:29

powered by OSQA