How can I have the right response to this http request?

Viewed 36

I created a HTTPS request script that it's used on a Jenkinsfile. When I do the deployment on jenkins it works and I can see on the CloudWatch logs that everything goes more or less well, my problem it's the final result. I know that it's something very simple, but I'm getting very confused!

In my script I have something like this. My post request do this:

curl -X POST \
    -H 'Authorization: '$token \
    -H 'Accept: application/json' \
    -H 'Content-type: application/json' \
    --data '{ "A": [ '$A' ], "B": [ '$B' ], "C": "'$C'" }' \
    $environmentUrl

And in my jenkinsfile I have something like this:

                    script {
                        sh "sh scripts/httprequest.sh " + params.A + " " + params.B + " " + params.C + " $token " + params.environment
                    }

On my logs my response request looks like this:

"body": "{ \"A\": [ something ], \"B\": [ something  ], \"C\": \"\" }"

But I want to have this:

"body": "{ \"A\": [ \"something\" ], \"B\": [ \"Something\" ], \"C\": \"\" }"

I know that it's something very simple like a "", '' or a , but I can't figure it out. Please can someone help me!!

1 Answers

I fix it like this:

--data '{ "A": [ "'$A'" ], "B": [ "'$B'" ], "C": "'$C'" }' 
Related