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
Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!
Help us plant more trees
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.