I am using postman to get certain responses. Below is my response.
Here I have some other api request links integrated with this response. Is there any possibility that I can get values inside these apis also. Its like retrieve values forom both parent api request and child api request.
I know this is possible using a java code. But is there any other exsiting software that I can use for this?
In your case I would recommend combining multiple requests into a chain or even a workflow. The idea is to have the first request fetch href endpoints that get called in subsequent requests. For that, the initial request needs a post-request test script that reads the href values from the response and stores it in a environment or global variable.
Like so:
// persist project href for next request
pm.environment.set("projectUrlPath", pm.response.json().embedded.elements[0]._links.project.href);
Your next request in the line would than use this variable to build the request url. Like so:
http://www.example.com{{projectUrlPath}}
The key is to correctly navigate to the right attribute in the response json JavaScript object. This online tool might help you with that:
https://www.w3schools.com/js/tryit.asp?filename=tryjs_json_parse
Related
I am exposing an endpoint e.g. example.com/transactions via Apigee. I am using a Proxy endpoint which routes to my Target endpoint.
If I hit xxx.apigee.net/transactions, i get back my entire payload just as if I hit example.com/transactions. So far so good.
However, if I want to view one specific transaction, going to xxx.apigee.net/transactions/1 does not work. How can I make Apigee understand it needs to pass /1 to the underlying proxy endpoint so that it returns the same as example.com/transactions/1?
How can I pass the {resource-path} variable?
The Apigee API gateway passes the value through already. There is no need for additional manipulation.
I recently started working on Rest Based Web services. Here I have a requirement where I need to validate the contents of the request based on a parameter of request.
My question is What will be the best approach to do this validation.
I have two different JSON requests hitting my webservice.
Validate in the interceptor. This will need me to cast the request object back to its actual Type.
Validating the request in Controller.
Also I would like to know if filters can be used in this scenario and what benefit will it give me.
Thanks.
I have a page html let's call it abc.html
There are AngularJS fields embedded in it.
I am now writing a GET and POST in scala which routes the fuzzy search arguments to the proper page on the server.
I am trying to understand the sequence in which things occur in order to implement a GET/POST requests (written in scala) which would happen when someone makes a search on the search bar on the abc.html page, and which would return elements from the database
Is it abc.html (search) --> http GET request --> backend ( AngularJS) --> Database?
In this case this would mean my http post or get request would pass in the html data model elements which would in turn hit the backend AngularJS controller page which in turn would hit the database, and the return ride would send the database results via an http request to the page?
Do I need to explicitly define my GET in terms of angular fields and the database model?
thanks
HTTP uses request-response pairs. This means you don't have to make another request to return anything to the client, you just need to write the proper response. Other than that, your idea is fundamentally right. The process would look something like this:
Type something into the search form on your HTML page
Submit the search form to your backend. This creates a GET or POST request depending on your form element's method attribute.
(At this point the browser is awaiting a response)
As the request reaches the server, your backend code can capture its data and make a query to your database.
(At this point the server is awaiting data from the database)
The database returns its results, your backend code is free to format it into a response to the client's original request.
The client receives the response and you can use your frontend code to display it to the user.
What's the best way to send multiple parameters on a REST GET resource call. Normally we can call GET call with path param &/ query however the number of character is limited on a URL so any suggestion or best practice on how to achieve this.
This can be achieved via POST where sending the query in request body as JSON and use json converter on the resource end. I am thinking POST mayn't be a right approach for query or get service from a resource.
I search the existing questions on this but didn't get any proper answer.
Thanks in advance.
You can send a limited data with GET and even the data is visible in URL making data vurnerable. When you use POST data is a alot more safer than GET and you can send large no. of request parameters. You can checkout this link
Does JSON messages sent over HTTP in response to a URL request make it REST-compliant?
I believe it is not.
But I am not sure on the detailed reason.
If i have a well-organized website,which responds to URL requests with json representation payload - what does it need to do further to comply with RESTful or JAX-RS?
A simple concise explanation will be much appreciated
There is no restriction regarding the payload of messages in REST and using JSON format in HTTP responses isn't enough to make a service RESTful.
To make short (since it's what you asked for ;-)), what is really important in REST is to respect the HTTP operations (GET, POST, ...) are designed for, the concept of resources and their states (idempotence, ...), leverages headers and status codes, ...
The following link could give you hints about the way to implement a RESTful service / Web API:
Designing a Web API - https://templth.wordpress.com/2014/12/15/designing-a-web-api/
Hope it helps you,
Thierry
JSON is a payload and does not play any role in making your Webservice REST-complaint.
Payload could be XML, CSV, plain text etc etc.
The Webservice will be REST-Complaint when it's following REST protocol (set of rules, not network protocol).
There are up to 4 levels where you can make your REST webservice complaint to.
One of the very basic rules to understand is that - Your Request must not be RPC i.e. you MUST not perform any action using a Payload (Typical SOAP) or URL tunnelling e.g. http://www.example.com/product?id=1234&action=delete
In RESTful world you would define one top level URI for the above. e.g. http://www.example.com/product
and then you will call various URLs to perform other actions.
Such as:
POST - create Data
http://www.example.com/product
Body{ here your payload will describe the Product.}
Assuming you rely on server gennerated product id then return type could be Product Id. Which is again should be set as LOCATION parameter of the return header.
PUT - Update Data
http://www.example.com/product/1234
Body{ here your payload will contain the Product details to change.}
GET - Get Data
http://www.example.com/product/1234
DELETE - Delete Data
http://www.example.com/product/1234