{
"type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
"title": "Bad Request",
"status": 400,
"o:errorDetails": [
{
"detail": "Error while accessing a resource. You have entered an Invalid Field Value {{packid}} for the following field: custrecordhj_tc_pkgcont_lineitemparent.",
"o:errorCode": "USER_ERROR"
}
]
}
I copied your JSON and sent it using Postman Echo as RAW\JSON and it went through ok.
It needs the quotes otherwise it doesn’t echo back the JSON correctly.
However, when being read as a binary file, its not reading it as a variable, but treating it as a string. (The same issue as you are having).
I thought you might be able to update the body using the pre-request script, but it doesn’t look like you can update the binary data like you can for a RAW\JSON body.
console.log(pm.request.body.file);
All this does is return the file name.
For RAW\JSON, you can do something like this.
const body = JSON.parse(pm.request.body.raw); // retrieve current body
// update the elements\object
pm.request.body.raw = body; // write back updated body
I don’t have an answer for this, but can confirm using Postman Echo that it doesn’t read the variable when its posted as binary data.
Ok, mdjones, Thank you for trying, anyway.
The content of the JSON file is going to be variable, but I take care of everything else outside postman. I only need his field to translate properly. So, the raw/json is no an option for me. I’ve tried using the “form-data” option, and specifying a “File” type variable, however, I’ve got another error, saying: “The provided content type is not supported. Use one of the supported values: application/vnd.oracle.resource+json; type=singular; charset=UTF-8, application/vnd.oracle.resource+json; type=collection; charset=UTF-8, application/json; charset=UTF-8.”
Well… How can I try raw/json, if I need to get the JSON content from a file in my working directory?
Maybe that’s what’s happening here… I need to learn how to do that.
When I say that “The content of the JSON file is going to be variable”, I mean exactly that. The JSON file is going to be different on each run, as simple as that.
Now, I’ve just decided to work around this issue, by not using variables in my JSON file, and just do a third request to do an update of the record I’m creating, with the value in an environment variable. This worked for my need right now.
I guess this case can be closed without a real resolution as of why the system could not replace the variable in the external JSON file I am using for the request body, with the value of the environment variable.
Thank you for trying, thou.