I have XCUI test cases in which some API calls are made. How can I get which API calls are being made and get request and response printed in console? - xcode

I have to find which API calls are made in the application. I am running the XCUI tests and to mock the API request and response I need to know which APIs are being called in that page. How do I know which API calls are made and how to get the request and response of the same printed in the debug console?
I have tried po self.actionContext.searchEndPoint which gives me endpoint. But I need to get the request and response.

Related

How to remove request body from subsequent requests in JMeter

I tried to create a test script in JMeter where I log in by using API. I created a test script by BlazeMeter chrome extension.
Some of my API calls fail because I am getting CloudFront error. I found out the issue is that GET requests contain a request body. GET requests cannot contain a request body on CloudFront. When I tried the same get requests in postman without request body, I didn't get any errors. I got the same error in postman if I added a body request. This way I can confirm this is the issue.
I am looking for a way how to remove body request from subsequent GET requests in JMeter to get rid of this error.
This is the original API call (sampler) with POST login api request:
After the POST request there is a redirection to a page that makes other GET api calls to fetch static files such js files, etc. The problem is that these GET requests also contain the same request body as the original POST call.
As you can see I can fetch statis files if I remove body request:
I tried to add preprocessor and postprocessor for original POST request, but I don't know how to access subsequent GET requests. I can access only original POST request:
Is there a filter or a way how to remove body request from GET requests?
I don't think it's possible, at least not with JMeter 5.5
If you take a look at HTTPSamplerBase source code you will see that the request body is being copied fully from the original HTTP Request sampler:
this.sampler = (HTTPSamplerBase) base.clone();
So the options are in:
Raise an enhancement requests via JMeter Github Issues
Amend HTTPSamplerBase code to remove the request data from generated AsyncSamples
Handle embedded resources download manually using Parallel Controller

Intercept HTTP Request in page

I am trying to make a scraper for a page of a supermarket. I noticed that this supermarket make API HTTP calls via AJAX, and if I enter to Inspect > Network then I can see the request headers of the calls I need.
Inside the requests headers there is an X-Token. If I use this X-Token with the URL via Postman I can get all the info in JSON format, which is better than scraping the web.
The problem is that this X-Token expires (I think, it still works). Is there any possibility to make a call to the page and "intercept" this API call in order to retrieve this X-Token and use it for the next custom requests?
I'am using Ruby on Rails :)

Is there any tool to debug the rest calls made by GraphQL Playground?

I'm not able to figure out why the REST API call works just fine in Postman but not in the GraphQL Playground. If I could see the actual REST call being made by GraphQL, would be helpful to debug the issue.
Firecamp's GraphQL client lets you test the GraphQL as an API call or as a Query way.
Here is the dedicated GraphQL client
Here is REST like GraphQL client
Note: Make sure that you double-check the method and headers while using REST-like GraphQL client. IN most cases method would be post and header should contains Content-Type: application-json / application/graphql
The GraphQL playground allows to send GraphQL queries/mutations to your GraphQL server. You can see the requests that are send using the network tab of a browser dev tools.
For example, if a server is in running at the following address http://localhost:4000/graphql, sending a query/mutation, a XHR request will be sent to it. In the Request Payload of the Headers section there is the query/mutation itself.
In the Response section you can see the returned response.
You can start having a look at the returned response of your query/mutation. Perhaps there is something wrong in the related resolve function in GraphQL.

Spring MVC REST API: Invoke controller method programmatically given URL and JSON request body

I have a general REST API (developed using Spring MVC) that takes a list of API requests as its request body.
Each API request in the list has its own URL and request body.
In the implementation of this general REST API, I need to call the corresponding Spring controller method (in the same app) for each of these individual API requests (with their appropriate URL and request body).
(I will then merge all those individual API responses and return it in one big response from the general REST API).
I've been searching around, but I'm unclear how to programmatically call Spring to execute each individual API request. I would ideally like to get back the ResponseEntity from each call instead of the actual JSON response.
(More information:
On the same app server as the general API, I need to translate the URL and JSON request body for each individual API into the arguments to the controller method. I also need to take the URL and have Spring determine which controller method to invoke itself.)
Any help would be greatly appreciated.
Thanks,
Matt
Answer depend on whether the individual URLs that you are planning to invoke is with in the same server (Accessible without using network call) or not
If it is with in the same app server, spawn multiple threads and invoke the individual methods and join the response together and send it back
If it is not within the same app server, there are many Async Restclients are there besides spring's own webclient/restTemplate etc

"Post" method test result error in JMeter API testing

I tried to run a POST method for API testing in JMeter, I have sent the parameters as needed, but still it shows cannot post.
What should I do to make it work?
user add post request
response message
If you are testing an API my expectation is that you need to send either JSON or XML payload using "Body Data" tab of the HTTP Request sampler.
You will also need HTTP Header Manager to send the relevant Content-Type header
References:
Building a SOAP WebService Test Plan
REST API Testing - How to Do it Right
Another way of building a web service test plan is executing the request(s) according to your test scenario using a 3rd-party tool like Postman or SoapUI and recording them via JMeter's HTTP(S) Test Script Recorder.
In the post request, you need to provide server name or IP address and port number respectively. If it still doesn't work, try changing the path by adding /api then /user/data. it works in some cases.
Hope this works out!

Resources