I am working on a project to create some reporting on user’s hours logged and the projects(issues) that they are logged to. We are needing a number of custom fields returned to get the appropriate issue details and worklog information. My call is to the /rest/api/3/expression/evaluate with the following call. My return is always a 400 error “There was an error parsing JSON. Check that your request body is valid.”. I’ve tried a number of different variations on the call but I cannot seem to get it to return data. Any help would be appreciated.
Modifying it to contain the quotes did not seem to help. Formatting was definitely wrong but it seems like something else is incorrect in the field results.
Irrespective of the expression being valid or not, the JSON request body itself is invalid, hence the error message you are getting.
Strings in JSON cannot use physical line breaks, so you must concatenate the expression string object into one long, continuos string. You cannot use JSON-like-formatting inside a string object.
Your JSON uses left and right quotation marks (“ and ”) as object delimiters. That too is not valid JSON. You must use double inverted commas (") to delimit objects.
Use a JSON linting tool to check your request bodies are correctly formatted before submitting them to a REST API endpoint
Hi @BartTitus
You must first make sure your JSON payload is correct and you don’t get the same error back. Then you’ll need to correct the Jira expression that is currently incorrect. For example, in the filter expression, you should use && to combine the 3 tests. There are other problems too. For example, accessing fields of the issue does not use “.fields” like it does in JMWE’s Nunjucks scripts but something like issue.customfield_12345
The request is invalid because the endpoint has no such request parameter called contextVariables, it only has a parameter called context.
The expression is invalid because there is no such context variable called projects (plural), only project (singular).
The expression is invalid for that declared context, because it uses an issues identifier which isn’t defined.
Use a REST API test tool FIRST to debug your API requests. Break the problem down into small chunks; start with a basic request that works, gradually add more functionality and find at which point things go wrong, then critically compare what you changed with what you find when you… read the documentation.