Closed mr097065 closed 4 years ago
@mr097065 Can you share a scaled-down collection (or API endpoint) which we can use to reproduce this issue?
URL: You can create a mock server in postman to utilize this as I have utilized my limit.
/addresses?country=AUS&id=AUG|5f246f9b-7c97-4233-8de7-2d57f74cd86b|7.7305OAUGGwvjBwAAAAAIAgEAAAAAB7zTAAAAAAAAADEAAP..ZAAAAAD.....AAAAAAAAAAAAAAAAAAAAMTc3IHBhY2lmaWMgaHd5AAAAAAA-$15&dataset=GNAF
Response: 200 ok
{ "addressLine1": "Level 2 111 Pacific Highway", "suburb": "SYDNEY", "postcode": "2000", "country": "Australia", "unitNumber": "Level", "level": “2”, "streetNumber": “111”, "streetName": "Pacific", "streetType": "Highway", "state": "NSW", "countryCode": "AUS" }
My local Newman Version = 4.5.3 ( JSONError comes on local too)
Below error comes while executing via Jenkins. Error I am getting: Unexpected token 'H' at 1:1 HTTP request parsing failed with error: "Malformed URI: /v1/addresses?country=A ^
This error comes in Newman only while in postman it works fine. Jenkins console logs:
@mr097065 Created a mock server as you suggested but still can't reproduces the issue locally.
I suspect it's something that MuleSoft might've patched in CloudHub (for security reasons) and now forcing consumers to encode the URI. Is it possible to encode URI in newman?
@mr097065 you can either manually encode the additional/unsafe characters which are not encoded automatically or add the following script as part of your Pre-request Script:
pm.request.url.query.each((q) => {
q.update(encodeURI(q.toString()))
});
This script mutates (encodes the additional characters) the request URL before sending it.
Also, can you verify that your request works fine in Postman after enabling the "Use next generation URL processing"
setting?
Thanks. Let me try that and also after enabling setting in postman to "Use next generation URL processing" it doesn't work in postman too.
@mr097065 Thanks for the verification.
With this new setting Postman encodes the URL based on the WHATWG URL standard (know more about this change) which is similar to most of the web browsers.
Are you facing a similar issue when you send this request from Chrome or any other browser?
@mr097065 The only character which is causing (because it's not encoded) this issue is |
which needs to be encoded as %7C
according to your request middleware.
Yes, I get same error in chrome when I hit the URL there.
Below is the error in chrome. HTTP request parsing failed with error: "Malformed URI: /v1/addresses?country=AUS&id=AUG|5f246f9b-7c97-4233-8de7-2d57f74cd86b|7.7305OAUGGwvjBwAAAAAIAgEAAAAAB7zTAAAAAAAAADEAAP..ZAAAAAD.....AAAAAAAAAAAAAAAAAAAAMTc3IHBhY2lmaWMgaHd5AAAAAAA-$15&dataset=GNAF"
I just added the provided code in Pre-request Script and it started working fine in postman even after enabling the in "Use next generation URL processing" setting, but as soon as I executed the same request in my local Newman it again failed.
Yes you are correct only the pipe sign is not getting decoded properly. I will try to decode manually and then run in Newman
@mr097065 This is probably because of parsing invalid/non-JSON string (maybe the response is different).
Also, This change in the URL processor is enabled by default since Newman v5. I think you are using an older version of Newman locally and v5 on Jenkins.
Yes I am using old version just updated Newman to V 5 and voilà it worked. Closing this issue. Thanks alot for your help.
newman -v
):