Forum Discussion
If a header (like the token) is required with all requests for a resource/method then the header parameters should be added at that resource/method level. When any new request is created the parameter will be added with the default value so there is less chance of missing or incorrect parameters.
The default value for the parameter can be changed or left blank in each request test step if necessary.
If a header is only required for one specific request then it can be added on the headers (horizontal tab) without changing any other requests.
- tgunasek7 years agoNew Contributor
Many thanks for the clarification around the header. Just curious about the other horizontal panels such as "Auth", given that you have mentioned the Horizontal Request panel only applies to individual requests. Does that mean Authentication configured through that tab would only apply to a individual request, and that you could have different authentication configurations for different requests within a individual REST service project in ReadyAPI?
This next question isn't really around the header, but as it's related to one of the REST service API methods I'm attempting to test, I'm raising it under this topic. This is the JSON request code snippet which I've been given to try & simulate/setup in ReadyAPI.
*******************************
HEADERS = {'apitoken': XXXX}resp = requests.post(
url= 'https://xxxx.xxxxxxx.com/rest/xxxx/search'
data={'name': nameArg, 'country': countryArg},
headers=HEADERS
)
*******************************Would you be able to confirm if this is the correct way to set it up in ReadyAPI? A JSON (not XML) request and response would be required here. The associated screenshot is attached.
Method = POST
Endpoint = https://xxxx.xxxxxxx.com
Resource = /rest/xxxx/search
Vertical Request Parameters tab line items:
Name: name, Value: nameArg, Style: QUERY, Level: METHOD
Name: country, Value: countryArg, Style: QUERY, Level: METHOD
Name: apitoken, Value: XXXX, Style: HEADER, Level: RESOURCE
MediaType = application/json
- tgunasek7 years agoNew Contributor
Having read through some further ReadyAPI Documentation, I see that the text area below the Media Type (application/json) dropdown is called the "Content Editor".
Is this where the json request body arguments should be set? I.e. rather than as request parameters under the Parameter editor?
HEADERS = {'apitoken': XXXX}
resp = requests.post(
url= 'https://xxxx.xxxxxxx.com/rest/xxxx/search'
data={'name': nameArg, 'country': countryArg},
headers=HEADERS
)I.e. for the JSON example I am trying to simulate/test (above) in ReadyAPI, should I be entering the following under the "Content Editor", instead of adding them as request parameters?
{'name': NameArg, 'country': CountryArg}
- PaulMS7 years agoSuper Contributor
Yes it seems that the name/country data would be included in the content editor so you don't need name/country parameters.
There is a JSON request example in https://support.smartbear.com/readyapi/docs/projects/ui/request/request/vertical/rest.html
The Raw panel is also useful to see the actual request that was sent
https://support.smartbear.com/readyapi/docs/projects/ui/request/request/vertical/raw.html
Authorization can be different for any request
https://support.smartbear.com/readyapi/docs/projects/requests/auth/index.html
Related Content
- 5 years agoSiKing
- 10 years agochuddy12345