Transfer dollar sign as is in the Json request
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Transfer dollar sign as is in the Json request
Hi
I have a JSON that contains in body "$" and I should transfer it By POST Rest request as is.
"value": "{\"container_procedures\":[{\"import\":{\"type\":\"LOAD\",\"json\":{\"file_path\":${PAPAYA_WORKING_DIR}\/quay.io.biocontainers.fastqc.0.11.8--1.tar\"}"
But this character is known as a dollar sign in the body of REST and transferred as an empty value :
"value": "{\"container_procedures\":[{\"import\":{\"type\":\"LOAD\",\"json\":{\"file_path\":\"\/quay.io.biocontainers.fastqc.0.11.8--1.tar\"}
I tried with \$ but it doesn't help.
could you please advise how can I solve it?
Thanks
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Rivka
you've injecting escaped .json (which makes it a lot more difficult to read) rather than unescaped .json.
once the escaping is removed it reads as follows:
"value": "{"container_procedures":[{"import":{"type":"LOAD","json":{"file_path":${PAPAYA_WORKING_DIR}/quay.io.biocontainers.fastqc.0.11.8--1.tar"}"
which is malformed .json
you need to fix the .json so it's wellformed - then it will work properly.
There appear to be a number of issues making your .json malformed - no opening object/array opener, there is a single array opener but no closure for the array, and you're not closing any of the objects in there.
if you need to inject escaped .json rather than unescaped - don't forget to add the escaping once you've got your wellformed .json sorted!
Cheers,
richie
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Rivka
Ok - I tried fixing your .json and I've got it wellformed - but this is a guess - I don't know you're requirements - there could be arrays in there that I'm treating as objects - you need to confirm what the content is based on the requirements.
a wellformed example (not necessarily correct as I state above) is as follows:
{ "value":{ "container_procedures":{ "import":{ "type":"LOAD", "json":{ "file_path":"${PAPAYA_WORKING_DIR}/quay.io.biocontainers.fastqc.0.11.8--1.tar"} } } } }
I escaped the above string and it generated the following:
{ \"value\":{ \"container_procedures\":{ \"import\":{ \"type\":\"LOAD\", \"json\":{ \"file_path\":\"${PAPAYA_WORKING_DIR}\/quay.io.biocontainers.fastqc.0.11.8--1.tar\"} } } } }
As I say - the above isn't necessarily correct - I've just made some changes to make a wellformed esaped .json out of the malformed example you gave,
Hope this helps!
richie
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @richie
I send you before only the problematic part of the JSON and not all content (please ignore about the form of JSON if you see anything related it )
This is the content of JSON
{
"display": "TESTING",
"description": "Run python tool",
"metadata": {
},
"inputs": ["imagename",
"in1",
"in2",
"in3",
"in4"],
"steps": [{
"reference": "Step/980",
"display": "run_jnj_qc_docker",
"arguments": [{
"executableId": "279",
"commandDisplay": "rundocker",
"parameterType": "PARAMETER",
"display": "payload",
"value": "{\"container_procedures\":[{\"import\":{\"type\":\"LOAD\",\"json\":{\"file_path\":\"${PAPAYA_WORKING_DIR}\/quay.io.biocontainers.fastqc.0.11.8--1.tar\"}},\"run\":{\"json\":{\"image\":\"quay.io/biocontainers/fastqc:0.11.8--1\",\"detach\":true,\"auto_remove\":false,\"command\":[\"fastqc\",\"-o\",\"analysis\",\"analysis\/%SEQUENCE%_L001_R1_001.fastq.gz\",\"analysis\/%SEQUENCE%_L001_R2_001.fastq.gz\",\"analysis\/%SEQUENCE%_L002_R1_001.fastq.gz\",\"analysis\/%SEQUENCE%_L002_R2_001.fastq.gz\"],\"volumes\":{\"\/scratch\/\":{\"bind\":\"\/references\",\"mode\":\"ro\"},\"${PAPAYA_WORKING_DIR}\/\":{\"bind\":\"\/analysis\",\"mode\":\"rw\"}},\"stdout\":true,\"stderr\":true}}}]}"
}]
}]
}
"value" field should contain text value only so you can see the JSON for this field with slashes.
Thanks
Rivka
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Rivka
The trouble is that the problem is most likely to be that the json is malformed.
I am using paramaters/properties in the payload of the tests I'm currently working on in ReadyAPI! - and it works fine and picks ups up the property/value correctly.
The easiest way to work out what the problem is (if it isn't malformed .json) is still to get the .json wellformed so json parsers can read the .json and help me analyse the json to assist in identifying the problem.
Hence the reason if at all possible to always provide the full payload (with security detail removed) when posting queries on the forum - it makes identifying the problem a lot easier - cos one issue can mask another.
Another way of looking at this is that ReadyAPI! has to read your .json to manipulate it/use it properly and so must use a .json parser. HOWEVER - if the .json is malformed the parser can't read the .json and so ReadyAPI! won't do what you need it to do. Before ReadyAPI! can do anything with your payload/message - ReadyAPI! needs to parse your message - so it makes sense to fix any malformed issues first - cos in this case, the malformed .json will definitely mask the issue - i.e. no replace your parameter with a property cos it can't read it.
I did check the latest .json you posted and it's still malformed.
if you want to prove that the issue is/isn't being masked by the malformed .json you could create a VIRT that responds to your request and just include something like the folllowing as the payload:
{ "file_path":"${PAPAYA_WORKING_DIR}/quay.io.biocontainers.fastqc.0.11.8--1.tar" }
to prove that this successfully picks up the property you've parameterised?
cheers,
rich
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear @richie
I'm sorry maybe I was not clear with my question
I don't want to translate PAPAYA_WORKING_DIR to any value.
I don't want the function of dollar sign at all.
I want to pass it as a text '${PAPAYA_WORKING_DIR}'.(with dollar)
you can get the following Json as an example (hopefully is not malformed) :
{
"display": "TESTING",
"value": "${PAPAYA_WORKING_DIR}"
}
in ReadyAPI it's translate to :
{
"display": "TESTING",
"value": ""
}
Note:
I have not any a parameter PAPAYA_WORKING_DIR and it's should not be also.
I want to pass it as is in the request.:
{
"display": "TESTING",
"value": "${PAPAYA_WORKING_DIR}"
}
I hope it's more clear now.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Rivka
Ok - now I understand a little better - sorry - sometimes I don't read people's posts properly - so at the moment
{ "display": "TESTING", "value": "${PAPAYA_WORKING_DIR}" }
is being transformed to
{ "display": "TESTING", "value": "" }
This is because ReadyAPI! is interpreting "${PAPAYA_WORKING_DIR}" as a parameter and I'm guessing it can't find what "${PAPAYA_WORKING_DIR}" represents - so it's blanking the value.
stick another $ sign in there - so it reads as follows:
{ "display": "TESTING", "value": "$${PAPAYA_WORKING_DIR}" }
this will generate
{ "display": "TESTING", "value": "${PAPAYA_WORKING_DIR}" }
cool?
cheers,
rich
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
