My boss told me to compare json response and automate it. For eg: Store the json response which are coming from server and store them in one file now make second file to call first file and compare each json response. If response is right then automatically it will check mark saying "all response are correct" and vice versa. But I don't know how to do it. Can anyone guide me ?
Related
I have a C# project that
gets a request to do work
performs the work
returns to the api a json object containing the results of the request
This is working fine. As the work is done there is a log file that gets populated with various information (date being processed, errors encountered, etc.). I want to include a request type that would tell my program to return to the API the log file. Because I want this to be "just another request" I am trying to figure out how to include the file as part of the json body being returned. Is this possible? Is there a way to include a file (actual file - not just the contents of the file) in the json body?
I know how to return the file as it's own post - is there a way to return a json AND a file in the same post or am I looking at 2 separate post requests? One for the json body and a separate post that would send the file?
I have a logic app that runs as follows:
Step 1 = Recurrence (the schedule for the logic app to run)
Step 2 = HTTP (Performing a POST call on a custom API that returns a JSON file)
Step 3 = Create Blob (which uploads said document from Step 2 and uploads it to blob storage)
What I would like to do now is add an extra step between Step 2 and Step 3. After making the HTTP POST call, I would like to verify the content inside the JSON file that gets returned. If there is an error present in the JSON file, I want the Logic App to stop there.
Is there a particular step that I can use in Azure's Logic App to verify the data and have that step decide if it should continue on or not.
For this requirement, you can refer to my logic app below:
1. I initialize a variable named "resultFromHTTP" to simulate the json from your HTTP request(step 2). And I delete some character, so the "resultFromHTTP" is not a valid json format.
2. Then I initialize another variable and use the expression json(variables('resultFromHTTP')) in its value.
3. Run the logic app, it will fail and show error message like below screenshot. If the json is in valid format, it will run success.
===============================Update==============================
For your latest question, if the result json from HTTP request is not in valid json format and not a very long string, you can do it like this:
The contains(... expression is contains(variables('resultFromHTTP'), 'Data Not Found'). Then you can do what you want under "if true" or "if false".
If the result json from HTTP request is in valid json format, you can use "Parse JSON" action to parse it and get the specified field and then judge if it equals to "Data Not Found".
For Example,
I have a document in my CouchDB database that holds two fields
"password" and "username".
This is the URL for my document:http://127.0.0.1:5984/_utils/document.html?sgram/fdcfc14940fbaa0d86674046ce005107
I want to retrieve the value of these fields from that specific document in CouchDB and parse it in Xcode.
I tried using http-get but it just returns the entire page source.
You want to make a request to this endpoint
http://127.0.0.1:5984/sgram/fdcfc14940fbaa0d86674046ce005107
For a json response from couchdb just don't include _utils/document.html in between. If you do it will give you back the futon html page.
I have an application which uploads a large file in the XML format and sometimes a zip file. Now I want to have that file transferred to other application via REST API. I am thinking to pass the binary data in to json response.
I have the following questions for my approach.
Is sending binary in json the best approach/practice to do it?
Will this be PUT scenario as receiver application doesn't know about new uploaded file?
If that makes it easier for the second service to consume it, I see no problem with it. You can send it on any format you want, as long as it's accepted and you're setting the Content-Type and Accept headers properly.
You use a PUT only when you're sending a complete replacement of the resource at the target URI. If you know the final URI for that and if a GET to the same URI right after the PUT will retrieve as response the same body you just submitted, it makes sense to use PUT, otherwise, use a POST.
I'm learning how to use a third party API called Wunderground and I don't know how to request, receive, and use their results which is in a Json format.
If you see their website a developer can sign up for free and receives an API KEY. You can then request weather data in the following URL format.. http://api.wunderground.com/api/KEY/FEATURE/[FEATUREā¦]/[SETTINGā¦]/q/QUERY.FORMAT
So I have tried it in my web browser by typing some parameters and I received a very long Json file with the correct information (I checked). Problem is I don't have the slightest idea of how to create a variable which can make this request, and even if I was able to do that I don't know where should I receive the file and how to get only the results I want (in this case current weather).
You have to use Titanium.Network.HTTPClient to make request.
For code examples related to Json parsing you can use:
Appcelerator: Using JSON to Build a Twitter Client
HTTPClient()