Forum Discussion

Rivka's avatar
Rivka
Occasional Contributor
6 years ago

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

  • 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

     

  • richie's avatar
    richie
    Community Hero

    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

     

    • richie's avatar
      richie
      Community Hero

      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

       

      • Rivka's avatar
        Rivka
        Occasional Contributor

        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