PxPlus User Forum

Main Board => Discussions => Web Services => Topic started by: HendersonS on September 04, 2025, 05:09:59 PM

Title: Unexpected Response in an HTTP Request
Post by: HendersonS on September 04, 2025, 05:09:59 PM
Hello everyone, we are working with a third party API that we send xml files, and we are getting an unexpected response when we tried to post a file using the pxplus *plus/web/request utility, but when we use postman we get the expected response, we compare the raw http post, and initially we don't find any relevant differences.

this example of what we send from pxplus:
POST https://web.com/endpoint HTTP/1.1
Content-Type: multipart/form-data; boundary=----PxPlusFormDataBoundary_jqePihSICwS9OCggqvv6pcSWx53Sr4PI
Content-Length: 5506
User-Agent: CustomApp/3.5.1
accept-encoding: gzip, deflate, br
Accept: application/json
Authorization: bearer yJhbGciOiJIUzIfQ.VDMfa9MhV...
Host: web.com
Cache-Control: no-cache

------PxPlusFormDataBoundary_jqePihSICwS9OCggqvv6pcSWx53Sr4PI
Content-Disposition: form-data; name="xml"; filename="file_name.xml"
Content-Type: text/xml

<?xml version="1.0" encoding="utf-8"?>
<XMLCONTENT>
...HH
</XMLCONTENT>

------PxPlusFormDataBoundary_jqePihSICwS9OCggqvv6pcSWx53Sr4PI--

and this is the response:
HTTP/1.0 400 Bad Request
Content-Type: text/html

<html><head><title>Error</title></head><body>
<h2>ERROR: </h2>
<br>
</body></html>



this example from Postman:
POST https://web.com/endpoint HTTP/1.1
Authorization: Bearer yJhbGciOiJIUzIfQ.VDMfa9MhV...
User-Agent: PostmanRuntime/7.39.1
Accept: */*
Cache-Control: no-cache
Postman-Token: 84e36083-e8d2-45c0-a796-8ceba.......
Host: web.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Type: multipart/form-data; boundary=--------------------------016854827228628556451404
Cookie: citrix_ns_id=AAI7XMG5aDvuodAGAAAAADtph5H_folAahaJO3ZgXF47eTRF6UPCLl86FZ_BO32DOw==Wci5aA==DQb-sHYMQEWeET5gyA37CgIG7zs=
Content-Length: 5500

----------------------------016854827228628556451404
Content-Disposition: form-data; name="xml"; filename="file_name.xml"
Content-Type: application/xml

<?xml version="1.0" encoding="utf-8"?>
<XMLCONTENT>
...HH
</XMLCONTENT>

----------------------------016854827228628556451404--

and the response is the expected json.

so What could be causing us not to have the same response in pxplus?

thanks in advance,
HendersonS.

Title: Re: Unexpected Response in an HTTP Request
Post by: Loren Doornek on September 04, 2025, 06:47:13 PM
The Content-Type is "text/xml" in the PXP version, but "application/xml" in the Postman version.  That may affect how the API host is interpreting the data.
Title: Re: Unexpected Response in an HTTP Request
Post by: HendersonS on September 04, 2025, 08:51:48 PM
Thanks Loren for your reply. We saw that small difference and made the change, but we had the same results. We think it must be something with the headers, but we can't figure out what the error is.
Title: Re: Unexpected Response in an HTTP Request
Post by: Devon Austen on September 05, 2025, 08:53:10 AM
In the PxPlus request you have

Authorization: bearer yJhbGciOiJIUzIfQ.VDMfa9MhV...

while the postman request you have

Authorization: Bearer yJhbGciOiJIUzIfQ.VDMfa9MhV...

The b in Bearer I would guess needs to be capitalized.

In you *plus/web/request when setting the extra headers make sure you use a capital B.

Title: Re: Unexpected Response in an HTTP Request
Post by: HendersonS on September 05, 2025, 01:53:27 PM
Thanks Devon for your reply, we tried that change but we have the same results, any other ideas?
Title: Re: Unexpected Response in an HTTP Request
Post by: Devon Austen on September 05, 2025, 02:38:54 PM
Not sure.

accept-encoding is also lower case?

Accept header is different?

Content length is different?

Are you using the latest version of PxPlus there have been improvements and bug fixes to *plus/web/request over the years?
Title: Re: Unexpected Response in an HTTP Request
Post by: HendersonS on September 05, 2025, 09:54:10 PM
devon we saw those small differences but technically this should not have a negative impact on the http request, however we have made the changes so that it is exactly like in postman, except for the postman-token, the cookie and the content-length, which according to pxplus that would be the correct size (5506), I don't know why in postman it is a little smaller (5500), we are using pxplus 2025, but we have tried with several versions and we have the same results, the truth is we are running out of ideas, maybe we have to use powershell or c# to make the http request
Title: Re: Unexpected Response in an HTTP Request
Post by: Devon Austen on September 08, 2025, 07:55:39 AM
The size of the content is what I would expect is the issue. If you are sending a request and getting a bad request error maybe the extra 6 bytes you are sending via PxPlus are the cause.
Title: Re: Unexpected Response in an HTTP Request
Post by: HendersonS on September 09, 2025, 01:55:33 PM
Devon, we used the CALL "*tools/readfile",path$,xml_str$ tool to read the file, so I believe the length is correct.
Title: Re: Unexpected Response in an HTTP Request
Post by: Devon Austen on September 09, 2025, 02:35:45 PM
If that is the length of the file why is Postman sending less? What is postman not sending that you are with your PxPlus request?
Title: Re: Unexpected Response in an HTTP Request
Post by: HendersonS on September 19, 2025, 03:01:28 PM
Hi Devon, sorry for the delay in responding. We're trying to resolve this issue. We use byte counting, and the difference between the content length in Postman and pxplus is the Boundary length. Technically, this shouldn't affect the HTTP request, so we don't believe it's the issue. We're still trying to determine what the problem is. What do you suggest?
Title: Re: Unexpected Response in an HTTP Request
Post by: James Zukowski on September 19, 2025, 03:06:49 PM
This probably doesn't have a bearing on the situation, but do you have <CR> characters with the <LF> where POSTMAN does not?
Title: Re: Unexpected Response in an HTTP Request
Post by: HendersonS on September 19, 2025, 04:41:59 PM
James we have checked it and we have not found any difference in the body, it even has exactly the same length except for the Boundary.
Title: Re: Unexpected Response in an HTTP Request
Post by: Devon Austen on September 19, 2025, 05:09:12 PM
in pxplus request Accept: application/json
in postman request Accept: */*

in postman there is a Connection: keep-alive which is not in pxplus request

In postman there is a cookie header that is not in pxplus

Beyond the body those are the differences it is got to be one of those or we are missing something.