krppsamy
(great toknow)
May 19, 2025, 1:14pm
1
@danny-dainton @descent-module-engi4
I have a pre request script to send an api request to get some data on BE. this is POST request with raw cbor payload which contains ‘//’ special chars.
While sending this payload via pre request script using pm.sendRequest method, it is truncating the payload data that comes after ‘//’ char.
This request is working with postman ui request but not with native engine script.
For example:
const originalRawPayload = p2N2ZXJCAMVuA//EXoQoaODVRlSj0fe//6RuoVDSGN
;
Message that was sent in request: p2N2ZXJCAMVuA
Note: I cannot use JSON.stringify method as it will stringify the payload and it will not be accepted by our BE system.
I’ve just tested that against Postman Echo and I can’t seem to replicate it.
Your screenshot seems to show backticks instead of normal single or double quotes (is there a reason for that?).
const originalRawPayload = `p2N2ZXJCAMVuA//EXoQoaODVRlSj0fe//6RuoVDSGN`;
console.log(originalRawPayload);
let request = {
url: 'https://postman-echo.com/POST',
method: 'POST',
body: {
mode: 'raw',
raw: originalRawPayload
}
}
pm.sendRequest(request, (err, res) => {
if (err) {
console.log(err);
}
});
Try escaping the special characters.
const originalRawPayload = `p2N2ZXJCAMVuA\/\/EXoQoaODVRlSj0fe\/\/6RuoVDSGN`;
1 Like
krppsamy
(great toknow)
May 20, 2025, 2:26pm
3
@michaelderekjones Thanks for the reply. I found the root cause of this issue.
When using my valid header value then the payload is truncated by // special chars.
For ex:
const originalRawPayload = `p2N2ZXJCAgBlc19raWRQ//EfQZp4JL4n+cYyOVAPQs93QtWtK1b5zX3
oJPU+0f+SbRlSj0fe//6RuoVDS9BRVMyNTZHQ0lnO2D/XBNQ4aWf2`;
console.log(originalRawPayload);
let request = {
url: 'https://enrollment-mgr-api.lan/enrollment',
header: {"Content-Type": "**application/vnd.comp.tec.enrollment-v0+json;security=sm2+cbor**"},
method: 'POST',
body: {
mode: 'raw',
raw: originalRawPayload
}
}
While using invalid {{bla-bla-bla}} header value the payload is not truncated
If I send your request to Postman Echo, it doesn’t seem to truncate the variable.
const originalRawPayload = `p2N2ZXJCAgBlc19raWRQ//EfQZp4JL4n+cYyOVAPQs93QtWtK1b5zX3
oJPU+0f+SbRlSj0fe//6RuoVDS9BRVMyNTZHQ0lnO2D/XBNQ4aWf2`;
console.log(originalRawPayload);
let request = {
url: 'https://postman-echo.com/POST',
header: {"Content-Type": "**application/vnd.comp.tec.enrollment-v0+json;security=sm2+cbor**"},
method: 'POST',
body: {
mode: 'raw',
raw: originalRawPayload
}
}
pm.sendRequest(request, (err, res) => {
if (err) {
console.log(err);
}
});
Are you running this from the Desktop Agent or the Web Client? (As I can see a slight discrepancy in the User-Agent runtime). 7.43.4 vs 7.44.0
krppsamy
(great toknow)
May 21, 2025, 8:07am
5
@michaelderekjones
But when you use header value as “application/vnd.comp.tec.enrollment-v0+json;security=sm2+cbor” it will truncate. Do not use ‘**’ as prefix or suffix.
Also find the below details
Postman for Windows
Version
11.46.2
UI version
11.46.2-ui-250519-2337
Desktop platform version
11.46.2
Architecture
x64
OS platform
win32 10.0.22631
Can you try running your request against Postman Echo?
Also, can you try the web client?
krppsamy
(great toknow)
May 21, 2025, 8:26am
7
I see that in your request header you are using "* * " as prefix and suffix. Can send the request without ‘* *’ in the header value.
That cuts some of the variable out, basically everything after the // on each line.
Is this supposed to be split over two lines?
I had to look up that content type.
rest - Header value: application/vnd.api+json - Stack Overflow
This seems to indicate that the body should be JSON at the core, but you just seem to have a string. I don’t know if that is causing Postman to format the body incorrectly. Need someone from Postman with a bit more knowledge to explain further.
krppsamy
(great toknow)
May 21, 2025, 8:50am
10
Yes sometime it has ‘\n’ value it converted into new line.
krppsamy
(great toknow)
May 21, 2025, 8:52am
11
Actual payload will be in JSON and encrypted with CBOR hence it supposed to be a raw request body
In your working request through the GUI, what content type is being sent there?