PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Jeffrey Ferreira on July 31, 2019, 01:07:44 PM

Title: *web\request
Post by: Jeffrey Ferreira on July 31, 2019, 01:07:44 PM
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",
Title: Re: *web\request
Post by: Mike King on July 31, 2019, 04:40:35 PM
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.

Title: Re: *web\request
Post by: Jeffrey Ferreira on August 01, 2019, 11:02:21 AM
Thank you Mike...including the boundary got me a lot further.
Title: Re: *web\request
Post by: HendersonS on April 01, 2024, 09:57:37 PM
Jeffrey Ferreira,
I'm working on something similar, how did you create the boundary?