Hi,
I have the following code (in ScriptRunner):
TestGeos111(httpMethod: "POST"){ MultivaluedMap queryParams, String body ->
def curl = "curl \
-u <uname>:<password> \
-X POST\
--data '{"validator": "name","comments": [{"body": "Project has been validated."}],"items": [{"type": "hours","reference": "3HSWDEVELOPMENT","description": "Software engiener hours [Phase: 1.1.5. Layout void any misswork]","quantity": 66,"unitPrice": 500.00},{"type": "hours","reference": "3HSUPPORT","description": "Support Engineer hours [Phase: 8. Validation]","quantity":55,"unitPrice": 200.00}]}' \
-H Content-Type:application/json \
https://ebes.example.com/API/Engineering/Analysis/Validate?Plant=EAES&PartNumber=R170025Y001001"
def output = curl.execute().text
}
but i get below error . Is my way to pass json body is incorrect ? please help me with this .
Hello @sgole ,
I might not be the best person to answer this question since I don't use scriptrunner myself but, reading the returned error message, it looks like the part of text inside the square brackets is not treated as normal text:
[Phase: 1.1.5. Layout void any misswork]
Now, even if the below body looks correct, can you kindly try the following:
curl \
-u <uname>:<password> \
-X POST\
--data '{"validator": "name","comments": [{"body": "Project has been validated."}],"items": [{"type": "hours","reference": "3HSWDEVELOPMENT","description": "Software engiener hours [Phase: 1.1.5. Layout void any misswork]","quantity": 66,"unitPrice": 500.00},{"type": "hours","reference": "3HSUPPORT","description": "Support Engineer hours [Phase: 8. Validation]","quantity":55,"unitPrice": 200.00}]}' \
-H Content-Type:application/json \
https://ebes.example.com/API/Engineering/Analysis/Validate?Plant=EAES&PartNumber=R170025Y001001
TestGeos111(httpMethod: "POST"){ MultivaluedMap queryParams, String body ->
def curl = "curl \
-u <uname>:<password> \
-X POST\
--data '{"validator": "name","comments": [{"body": "Project has been validated."}],"items": [{"type": "hours","reference": "3HSWDEVELOPMENT","description": "Software engineer hours","quantity": 66,"unitPrice": 500.00},{"type": "hours","reference": "3HSUPPORT","description": "Support Engineer hours","quantity":55,"unitPrice": 200.00}]}' \
-H Content-Type:application/json \
https://ebes.example.com/API/Engineering/Analysis/Validate?Plant=EAES&PartNumber=R170025Y001001"
def output = curl.execute().text
}
I hope this helps.
Cheers,
Dario
At the American Academy of Family Physicians, siloed marketing teams faced delays and duplicate work. Kerrie Gottschalk shook things up by moving the department to Jira, streamlining processes, boosting visibility, and sparking stronger collaboration.
Read the story
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.