Hi automation testers !
My problem
I am having troubles trying to make a sample web service project !
_I am trying to create a sample tests for REST JSON API https://jsonplaceholder.typicode.com/._
What I do with success
I have successfully done 1 request ‘Create album’ (POST to https://jsonplaceholder.typicode.com/albums)
with json body as:
{
"userId": ${userId},
"title" : "${title}"
}
and i’ve defined the two variables with default values in variables section.
<variables>
<defaultValue>1</defaultValue>
<description></description>
<id>a7bcad4d-3d63-47a8-9e00-d6179f6f44da</id>
<masked>false</masked>
<name>userId</name>
</variables>
<variables>
<defaultValue>'My sample album title'</defaultValue>
<description></description>
<id>716b919a-2c2c-4a95-a336-954a6b55237f</id>
<masked>false</masked>
<name>title</name>
</variables>
And this request works well !
I get response 201 as expected
What i cannot do
I am trying to do request Create comment with same method ans POST tout /comments
I have body json as :
{
"postId": ${postId},
"name" : "${name}",
"email" : "${email}",
"body" : "${body}"
}
Variables as :
<variables>
<defaultValue>1</defaultValue>
<description></description>
<id>dfcf3e15-1b48-4880-8217-9ad7b15dede3</id>
<masked>false</masked>
<name>postId</name>
</variables>
<variables>
<defaultValue>'katalonsample@yopmail.com'</defaultValue>
<description></description>
<id>5cdbd2a6-93eb-4fa4-9c4f-bc7ccfdb7262</id>
<masked>false</masked>
<name>email</name>
</variables>
<variables>
<defaultValue>'My sample comment'</defaultValue>
<description></description>
<id>c9d3171d-69d3-4245-a8c0-069baaff34d1</id>
<masked>false</masked>
<name>name</name>
</variables>
<variables>
<defaultValue>'est natus enim nihil est dolore omnis voluptatem numquam\\net omnis occaecati \tquod ullam at\\nvoluptatem error expedita pariatur\\nnihil sint nostrum voluptatem reiciendis et'</defaultValue>
<description></description>
<id>3c403665-0a4c-4a7d-b413-d1f9bedb63e5</id>
<masked>false</masked>
<name>body</name>
</variables>
And this request fail every single time with response :
SyntaxError: Unexpected token in JSON at position 191
at JSON.parse (
<anonymous>)
at parse (/app/node_modules/body-parser/lib/types/json.js:89:19)
at /app/node_modules/body-parser/lib/read.js:121:18
at invokeCallback (/app/node_modules/raw-body/index.js:224:16)
at done (/app/node_modules/raw-body/index.js:213:7)
at IncomingMessage.onEnd (/app/node_modules/raw-body/index.js:273:7)
at IncomingMessage.emit (events.js:189:13)
at endReadableNT (_stream_readable.js:1103:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
I cannot figure out what’s wrong it is just the same request as the first one, i have checked json validators and everything …
Can you try it on your own ? Help me ? Any ideas ?
Thank you mates
Regards,
Adrian