Trying to populate field via API with a GET request

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Trying to populate field via API with a GET request

don_m
This post was updated on .
I am trying to populate a field based on a button action. The button triggers an action that calls an http service that calls the API using GET passing employee_id that returns a JSON file.
Problem 1: I am not passing the employee_id in GET with a value pulled from the corresponding field (I have hard coded a value in the screenshot). How do you do that? Note that I am contacting a CDATA API:

We’ve determined that my standard format query string
https://<url>/apiserver/api.rsc/Datamart_TeleWork_dbo_telework_form?employee_id=100001

… needs to be formatted in the CDATA way:
https://<url>/apiserver/api.rsc/Datamart_TeleWork_dbo_telework_form?$filter=employee_id eq 100001

or

https://<url>/apiserver/api.rsc/Datamart_TeleWork_dbo_telework_form(employee_id = 100001)

You can't do either from the GUI so I am guessing this  has to be done from direct coding.


Problem 2: I think I am messing up on the xpath syntax in the second tab of the Actions editor but I cannot determine the correct syntax from the examples I have been able to find. I have included screen shots below. Any help would be appreciated.

The form field I want to populate is called "ministry"
The dataset I have defined is called "api-dataset"
The action I have defined is called "api_action"
The http service I have defined is called "api_test"

I have included screen shots of what I think are all the relevant tabs below:


The form call to api-dataset asking for ministry data:



The first tab of the actions editor:



The second tab of the actions editor (this is where I think my mistake might be):



The third tab of the actions editor (where the dataset is defined):



The first tab of the http services editor where the GET call is made (test comes back with a 200, and JSON data):



The test response showing the JSON file returned.







Reply | Threaded
Open this post in threaded view
|

Re: Trying to populate field via API with a GET request

Erik Bruchez
Administrator
A few things to unpack here.

Regarding the URL, try using a template (with curly brackets that will fetch the `employee_id` field value from the internal XML data):

    https://<url>/apiserver/api.rsc/Datamart_TeleWork_dbo_telework_form(employee_id = {//employee_id})

It doesn't seem that you need anything in "Service Request Actions" at all, since you are doing a GET which doesn't have an HTTP body.

-Erik