*web\request

Started by Jeffrey Ferreira, July 31, 2019, 01:07:44 PM

Previous topic - Next topic

Jeffrey Ferreira

Hello List,

I'm using *web\request to communicate with a web\service. I'm quite new to the whole posting to a web service....
I'm having trouble with one of the POST's.

Someone has shown me a tool call post-man to show me what the code looks like in other languages  (like python, node, javascript, etc)
and all of them do this thing where they wrap the POST_BODY in this webkitformboundary

my post fails...
i'm just curious...do i have to do this webkitformboundary or does *web\request do this for me...

payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"filename\"; filename=\"DiscountUpdate.xml\"\r\nContent-Type: application/xml\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--"

headers = {
    'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
    'Content-Type': "application/x-www-form-urlencoded",

Mike King

If the post requires multi-part form data then you would need to create the boundary headers yourself, but I have rarely seen any 'Application-to-Application' transmissions that use multi-part form data transmissions. 

Generally for a post of XML you simply need to provide the XML as the posting data and set the transmission Content type to either "text/xml" or if binary data is involved  "application/xml".

A mutli-part form data transmission is generally only used when you have a web page that includes an attached file comes from a browser.  The web page form data (input fields) will be in one portion of the post, with the attachment(s) -- each separated by boundary lines and each with their our content-type specification.

Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Jeffrey Ferreira

Thank you Mike...including the boundary got me a lot further.

HendersonS

Jeffrey Ferreira,
I'm working on something similar, how did you create the boundary?