Forum Discussion

JustinM89's avatar
JustinM89
Contributor
8 years ago
Solved

Invalid JSON running script from Jenkins

I have a test case that runs fine when I execute it locally via ReadyAPI, yet fails with an invalid JSON error on a JSON datasource step when I run it from Jenkins.

 

My script setup is pretty simple:

Hit an endpoint that returns some JSON

Use this JSON as the input for a JSON datasource

 

Right before this datasource step, I logged the response that the previous REST request returns, and it is valid JSON (see attached file -- I had to remove all of the property names and values, but the structure is identical). I have also attached the stack trace that is produced by this error. I cannot figure out why this isn't working as I've checked into SVN all of the necessary files associated with this test case.

 

The only difference I can think of between my local copy of ReadyAPI and the copy on the Jenkins build server, is that I am running 1.9 locally while the build server has 1.8, but I'm not sure if this would cause such an error.

 

 

EDIT -- I get the same result running this test script command line from the Jenkins server, so the issue isn't strictly Jenkins. However, I am still confused as to why I am getting this error when the request is returning valid JSON.

 

EDIT 2 -- OK, the problem appears to be ReadyAPI 1.8 -- I still had this installation laying around on my local PC, and when I ran this script using the 1.8 testRunner, it failed with the Invalid JSON string error. Is there any particular reason why my JSON datasource step would work in 1.9 but not 1.8? Did it not exist in 1.8 or something?

  • The issue was the syntax I was using in my JSON datasource step to retrieve the response from the previous REST request. I was using the syntax $['someProperty'], which works in 1.9 but apparently does not work in 1.8. The syntax $.someProperty works in both.

     

    The more you know. Hopefully this helps somebody else.

1 Reply

  • The issue was the syntax I was using in my JSON datasource step to retrieve the response from the previous REST request. I was using the syntax $['someProperty'], which works in 1.9 but apparently does not work in 1.8. The syntax $.someProperty works in both.

     

    The more you know. Hopefully this helps somebody else.