Steps to create POST operations involving Parenthesis (for SDLC Version higher than 6.8.0)
- While creating POST Operation involving parenthesis, user needs to ensure that the container has all fields/keys present in Request JSON Body; for example in case of Artifactory Connector while creating AQL operation, Request JSON Body contains only 1 field:
items.find( { “repo”:{"$eq":“default-docker-local”} } )
- Right click on the top of the Container present on the floor, Navigate to Connectors → Operations → Add Operation.
- Select appropriate Connector and Connection Name from the dropdown and click on “Next”.
Enter all the details in ADD Operation form. Details to be entered are:
i. Add Operation Name
ii. Add Operation Description
iii. Add REST API/Endpoint of the Operation that you wish to create
Please note that if your api has input which you require to take from user, you need to provide that parameter/field inside the curly({}) braces. For ex.:
/api/search/aql?project=Gathr Analytics
In this API, the project parameter can have dynamic value (Currently 'Gathr Analytics'), so you need to provide the API something like below:
/api/search/aql?project={Project}
iv. Under Actions drop down select Add new record(s) as you are creating a POST operation to create data in your application using Gathr Analytics.
v. Select HTTP Method as POST.
vi. In Request JSON Body add the Request JSON Body that is required to create the respective operation.
For example in case of Artifactory Connector while creating AQL Operation, a sample Request JSON Body is as follows:
items.find( { “repo”:{"$eq":“default-docker-local”} } )
vii. User needs to have prior knowledge, whether the API consists of encoding or not, If API contains encoding, the user needs to select UTF-8 Encoding from the Encoding dropdown.
viii. After entering all the details click on NEXT.
When you click on NEXT, the user will be redirected to the third form that is Configure Query Parameters form. In the REQUEST TEMPLATE PARAMETER section, if the REST API has any context(input) then the user needs to configure that input here. Then go to the JSON BODY PARAMETERS section, where the mandatory key will be configured. Mandatory keys are the keys/fields that are required for write back, without these keys users will not be able to write back to the system. In the case of Artifactory Connector while creating the AQL operation the mandatory key is $.repo.$eq, we check the “Is this Input mandatory?” checkbox.
Please make sure to assign the correct Data Type for your fields, otherwise execution of the operations wouldn’t be successful due to the incorrect datatypes.
In the Header Parameters section, enter the following details:
Key: Content-Type
Value: text/plain
Click on Next after selecting the mandatory keys. Click on Next, user will be redirected to Select JSON Information form. On Select JSON Information form in Response JSON Body you need to give the Response body of your API. In the Loop element section, user needs to select the appropriate array required according to the one’s use case. For Example : If the sample response is:
[
{
“Key1”:”Value1”,
“Key2”:”Value2”
}
{
“Key1”:Value3”,
“Key2”:”Value4”
}
]
Here for the above sample response you would see $.[*] array in the Select JSON Response drop down.
On selecting $.[*] array you’ll get a data set with the columns shown above on Gathr Analytics:
Please note that the JSON response body you’ve added might not contain any array([*]), in that case the “Loop Element” section will remain empty and will generate the fields/columns values according to the object’s values (Keys present in the curly braces {}).
Click on Next.
Click on Next, you’ll be directed to Configure Dataset form. Enter the details like Dataset Name, Dataset Description in this form. User cannot complete Operation creation without creating a Primary Key.
The keys of the JSON response are mentioned in this form, user can select any relevant key(s) as your Primary Key, or you can Auto Generate Primary Key. User can change the field Name, Description, Business Type or Datatype but please keep in mind to not to change the path fields as it denotes the JSON path for columns.
Steps to run POST operation:
In order to run POST Operation you need to follow the following steps:
- Right click on top of the container and Navigate to Connectors → Imported Connector→
→ and run the operation.
For example, in the example it would look like Connectors → Imported Connector → Artifactory AQL → AQL.
- Once you click on the Operation name a Reduce data popup will appear click on APPLY and you’ll be directed to the Map Parameters popup where you need to map the mandatory parameters corresponding to parameters in your Request JSON Body.
For Example, for running AQL operation, Repository Name is a mandatory field, thus your container should contain the Repository Name on which you want to search the items.
NOTE: The Mapping Parameters will be the same as the Request JSON Body keys, Users need to carefully map the details that they want to write back to their systems.
- Click on Submit and if the write back is successful you’ll get a Request Execution Detail dataset and a dataset for which the write back was performed.
For example in the case of Artifactory AQL Connector when you run the AQL operation, the following two datasets will be generated:
AQL Search
Request Execution Detail
If you have any feedback on Gathr documentation, please email us!