I need to pass single text which is username in text format need to be converted to JSON format and pass it to Jira rest api.
Thanks for the trace. Unfortunately, it doesn't tell us much more, it shows you posting a 7-character body, and you get a 400 in response ("bad request"), unfortunately without any body with an error message.
However, checking the documentation, it seems that you need to send a JSON string, which means you need to enclose the text in double quotation marks. So instead of sending:
kau2cob
you need to send
"kau2cob"
Looking at your post again, that's exactly what you do there, since "body content" is the literal content, not an OutSystems quoted string :).
EDIT: there seems to be some more requirements, like setting both the Content-Type header (which is already set) and the Accept header (which is not), so you may need to add the latter. The easiest way to do that is to add a header Input Parameter to the method.
Hi Sowndhar,
What is the JSON format that you want to use? Is there any name of the property you want to use in your JSON string?
Like, { "username": "sowndhar.s@outsystems.com" }
Here username is the property / attribute name. What is the exact format of string you want to output?
Hi Ravi,
rest/api/2/issue/{issueId}/watchers
For this api,I need to send just username as string.The outsystems automatically creates request datatype as text but when I input this string it shows error 400.So I thought this input need to be converted to JSON format.
But in test area it is working correctly.
In this case you don't need a JSON string, it is just a plain string containing username.
Yeah,Ravi.I don't need JSON String.But when I give input userId as plain text it shows 400 error.
You will need to find out what it describes further than just 400 error.
HTTP 400 Bad Request
Usually APIs provide more information about what are you sending incorrectly. Find out more information from the Integration Logs by finding out your REST API consume call in that list.
I send the input through form.API returns http error code only and it didn't show any error message.
I customize the response.Here it is
.
You can see the full error response without modifying or customizing. Just login to the service center and visit Monitoring > Integration Logs and find your API call in that list.
It gives you all details about this error.
That's not quite true, you need to increase the logging level of the API, otherwise you won't see much detail.
Hi Killian,
Increasing the logging level may be required for the API calls which were successful. As she already mentioned the issue resulted in an exception. I believe it would still give all error details even if the logging level is not modified.
Here I attached the error detail..
That is not true. To see any details of the actual call, you need to set it at least to "Troubleshoot". Otherwise you will not get details (other than the call stack, which is useless).
Please check the post I linked. The error stack is useless here. You need the details from the integration logging to see what you sent to Jira and what the response is.
It will require integration log details not the standard Error Log. From the integration log details, you also find a button at the bottom, to download the HTTP Trace of that call. Please share that information here.
But you won't find that button, unless you have increased the logging level, that's what I was saying.
I hope Sowndhar might have already raised the error logging level by now :)
Let's wait for more logs.
That's correct.
Here the HTTP Trace file
That's correct.I need to add double quotation mark in input also.
Glad I could help. The takeaway here is: check the integration logging to see what you sent, and match that with the API specification. This will allow you to find the errors and correct them.
If you want to consume the Jira REST API, you need to follow the Jira specifications. Thinking "I get a 400, do I need it in JSON?" is not the way to go. Also, you'll almost never need to convert something to JSON yourself when consuming REST APIs, as OutSystems does that for you.
That said, since you are connecting to JIRA, did you check out the JIRA Connector in the Forge? Even if you don't want to use a Forge asset, you could check what's inside.
Hello Kilian,
Thanks,I will check out the Jira connector
Thank you so much @Kilian Hekhuis and @Ravi Punjwani for your time and this valuable answers.