I need to make a call to a php form located in an external system, in the call I also need to pass a parameter to receive a 0 as a result, since if I pass the empty parameter it returns a 1, is it possible to perform this task from a script? , I have tried making a rest call but I always get the value 1.
import static groovyx.net.http.ContentType.*;
def body_req = [
RESTClient client = new RESTClient('http://tic.eroski.es/');
HttpResponseDecorator respPost = (HttpResponseDecorator) client.post(
path : '/codigo/tic_finan/tic_finan_test.php',
body : body_req,
the correct format should be availble in the REST API documentation. If you can't find it in the docs, try to get an existing record from the REST API with a GET request and see how the json is formatted.
I would investigate the REST Endpoint with Postman or any other rest client and make the POST Request work from Postman first.
some quick pointers:
- use a try catch block to catch the exception
- define the body directly directly when you make the call
- use respPost.responseData
- loose the quotation marks for Json Keys
- print the json string youo are posting to see how it look
- set the correct header:
- check the status code ... respPost.statusCode. Is the api returning a 200?
def body_req = [
Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events