I am trying to GET some data from another server into Tally via an XML API. But from the Tally documentation, I can see how to do HTTP POST. But I don't know what is the step by step process to do the HTTP GET using RemoteURL TDL instruction and pass the HTTP Header parameters. Can somebody please help? A sample would be a great help. Thanks!
To fetch data from a remote URL, if you are using POST, you would need to create a report and attach it to the request - this report is actually the POST payload.
POST Request:
[Collection: MakePOSTRequest]
Data Source: HTTP JSON: <insert URL here>
Remote Request: <insert TDL Report Name here> : UTF8
Export Header: <Insert header here>
JSON Object Path: "."
For GET request, you don't need anything except the URL. In case you have query parameters, attach it to the URL directly.
[Collection: MakeGETRequest]
Data Source: HTTP JSON: <insert URL here>
Export Header: <Insert header here>
JSON Object Path: "."
Let's say you have one URL: http://localhost:8000/get_api_data, which accepts both POST and GET requests. Then for the POST request, you would add the parameters via the TDL report, whereas for the GET request, you'd simply add the parameters to the URL this way: http://localhost:8000/get_api_data?key1='xxx'&key2='yyy'.
Not Working for me too..
[Collection: MakeGETRequest]
Data Source: HTTP JSON: 'http://35.198.189.9/api/Send?UserId=11&Guid=123'
JSON Object Path: "."
Related
I have a POST Rest-Request which consumes a multipart/form-data with an (optional) file part and a json part. Now I try to setup a SoapUi Rest-Request to test the ressource.
The equivalent request in postman for that json part looks like:
Key: someKey, Value: {"some": "json"}, Content Type: application/json
The equivalent cUrl Request is:
curl -X POST http://some-url -F "someKey={\"some\":\"json\"};type=application/json"
How to achieve this with SoapUi? I tried all possibles I can imagine, also a parameter with a file containing this json object like I found in a similar question.
In REST API, specifically RestAssured, there is an option to remove the Query params, Headers, Cookies, Form params, Path params which is set in request after getting a response.
Is there an option to remove the multipart content set in request in REST API(RestAssured) after getting a response?
If you're looking a way to reuse the RequestSpecification object, then No, there are no reset method for all of these config.
You can create new RequestSpecification object each time you call the request. Sample here. https://stackoverflow.com/a/69569031/7574461
Note - I am very much new to all this. Apologies if anything is unclear.
My overriding aim is to pull out MOT history data for a large batch of vehicles from the DVLA API. I understand that this can be done using Postman, which I am using (on a 64-bit Windows laptop if at all relevant).
The DVLA provide the following instructions
====================================================
Getting started
All API interfaces are implemented as restful APIs and accessed over https.
To access API you will need an API key that uniquely identifies the source of the request. DVSA will give you an API key if it approves your application.
You should keep your API key secure, as DVSA manages throttling and quotas at an API key level.
Each request must have the following mandatory fields in the header:
Accept: application/json+v6
x-api-key:
Content-type field confirms that the response type is in JSON format, and the x-api-key field serves your API key to identify the source of the request.
Technical resources
Access the API at https://beta.check-mot.service.gov.uk/
This root URL will change when the service moves from beta to live.
These 4 endpoints equate to the 4 methods of using the API:
/trade/vehicles/mot-tests?registration={registration}
‘Registration’ is the vehicle registration number.
===================================================
In order to test that this is possible, I am entering the following single request into the bar in Postman, selecting "POST" and hitting "SEND"
https://beta.check-mot.service.gov.uk/trade/vehicles/mot-tests?Content-type=application/json&x-api-key=ABCDEFGH®istration=MYREG
n.b. no inverted commas or other punctuation surrounds the actual values for ABCDEFH or MYREG
Expected result: Some sort of JSON with MOT history for this vehicle
Actual result: {"message": "Missing Authentication Token"}{"message": "Missing Authentication Token"}
I am unclear on:
- whether I should be using POST
what the +v6 after the application is necessary (other documentation leaves it out)
Why "Accept" and "Content-type" appear to be used interchangeably in the documentation
Whether the ordering of the parameters matters
Whether this can be equally tested by simply pasting the url into a browser
Thanks for any help
Reading through the Documentation found here:
https://dvsa.github.io/mot-history-api-documentation/
It mentions that those fields should be added as Headers:
Each request must have the following mandatory fields in
the header:
- Accept: application/json+v6
- x-api-key: <your api key>
There are example cURL requests on the site to help you with creating the request.
If you use Postman's Import feature within the app (found in the top right), you can add this cURL request in the Paste Raw Text tab.
curl -H "Accept: application/json+v6" -H "x-api-key: <your_api_key>" https://beta.check-mot.service.gov.uk/trade/vehicles/mot-tests\?registration=ZZ99ABC
This will give you an example request of what it should look like. From here, you will be able to add in your own API Token and send the request.
If you are using Postman, you can use the Authorization tab right under the request to give the required mandatory header fields. Select Header from Add to drop down. You can also add additional headers information using the next tab named Headers. (for example, the accept-headers).
Edit:
Authorization:
Headers Tab
Normally, you should be getting the authorization token when you register to the site in question(x-api-key here).You need to figure out the value of that token from the initial call's response headers. According to the document which Danny shared, you will be getting x-api-key from them once they approve your request.
Edit:
Alternatively, you can use import feature as Danny suggested in his answer. At the end of the day, you need to add the values as headers instead of query parameters.
For anyone using Python with the MOT history api and getting the same error message, try GET:
import requests
url = f'https://beta.check-mot.service.gov.uk/trade/vehicles/mot-tests?registration={plate_number}'
payload = {}
headers = {
'Accept': 'application/json+v6',
'x-api-key': 'your-api-key'}
response = requests.get(url, headers=headers, data=payload)
data = response.json()
model = data[0]['model'] # get the vehicle model for example
print(model)
http request: http://ipAddress:Port/SomeResource?Param1=value1&Param2=value2&......
so on.
This is a http request sample in jmeter that hits a rest api and gets response in JSON format.
Here the challenge is Param1, param2, param3 .... these search parameters number is not constant it may change depending on the call so i am making a csv file that contains rows that contain search parameters in coma separated format.
CSV file is like
param1,param2
param1,param2,param3
param1
I am using a CSV data configure to pull data from the csv file and put it in the http request
And putting this in http request like
Now if the param is null i don't want see this in http request header
so how to do this in jmeter.
Remove all "Parameters" from the HTTP Request, it should be clean
Add JSR223 PreProcessor as a child of the HTTP Request sampler you would like to parameterize
Put the following code into "Script" area:
1.upto(4, {
if (vars.get('param' + "$it") != null) {
sampler.addArgument(vars.get('param' + "$it"),'someValue')
}
})
Add JSR223 PostProcessor as a child of the request you would like to parameterize
Put the following code into "Script" area:
1.upto(4, {
vars.remove("param" + "$it")
})
That's it, you should now get what you need. You will not see the changes in JMeter GUI, you will only be able to observe them in the runtime using View Results Tree listener
Below is service URL which return output in form of JSON.
http://localhost:8000/ByDept/ExmapleService?format=json
But I want to pass querystring parameter with this URL. Below is Service URL.
http://localhost:8000/ByDept/ExmapleService?abc=hello&format=json
here abc=hello is parameter which is pass through query string.
But using this url i am able to receive output in form of JSON.
So how we can pass parameter in form of query string and access response in json.?
The Content Negotiation section in the Routing docs shows different ways you can specify the response format, e.g:
/rockstars?format=json
/rockstars.json
In addition you can also specify a JSON response with the Accept Request Header, e.g:
Accept: application/json
Both of the above accept extra query params without changing the Response Type:
/rockstars?id=1&format=json
/rockstars.json?id=1
So I don't really understand what the question is.