PxPlus User Forum

Twitter Twitter Twitter

Author Topic: *web\request  (Read 1396 times)

Jeffrey Ferreira

  • Diamond Member
  • *****
  • Posts: 175
  • I must have taken a wrong turn at Albuquerque.
    • View Profile
*web\request
« 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",

Mike King

  • Diamond Member
  • *****
  • Posts: 3811
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: *web\request
« Reply #1 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.

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

Jeffrey Ferreira

  • Diamond Member
  • *****
  • Posts: 175
  • I must have taken a wrong turn at Albuquerque.
    • View Profile
Re: *web\request
« Reply #2 on: August 01, 2019, 11:02:21 AM »
Thank you Mike...including the boundary got me a lot further.