Beginner to API Json - Attempting to understand URL output - java

I am using FME to get output from the following: https://coronavirus.data.gov.uk/developers-guide
I am just a beginner and is first time I want to write this up. To generate an Output URL from this with the relevant columns, can anyone explain what I need to get the request URL. I am using GET as the HTTP method
An example of a url i get some data out of is - https://soa.smext.faa.gov/asws/api/airport/status/SFO
But when i try with the links below which i tested does not get any output https://api.coronavirus.data.gov.uk/v1/data?filters=areaType=nation;areaName=england&structure=%7B%22name%22:%22areaName%22%7D

https://api.coronavirus.data.gov.uk//v1/data?filters=areaType=nation;areaName=england&structure={"date":"date","areaName":"areaName","areaCode":"areaCode","newCasesByPublishDate":"2020-07-07","cumCasesByPublishDate":"2020-08-08","newDeathsByDeathDate":"2020-02-06","cumDeathsByDeathDate":"2020-06-09"}

This is a better link for you to try out.
https://api.coronavirus.data.gov.uk/v1/data?filters=areaType=nation;areaName=england&structure={%22date%22:%22date%22,%22areaName%22:%22areaName%22,%22areaCode%22:%22areaCode%22,%22newCasesByPublishDate%22:%22newCasesByPublishDate%22,%22cumCasesByPublishDate%22:%22cumCasesByPublishDate%22,%22newDeaths28DaysByDeathDate%22:%22newDeaths28DaysByDeathDate%22}
Took me a while to suss it out.

Related

Microstrategy URL API

Reading from this link, link, link, link, link and this SO answer about Microstrategy URL API, I want to pass the answer to one or more prompts in the request to that the report document is executed automatically without requiring the user to enter information.
When I tried to use valuePromptAnswer method for multiple prompt, Microstrategy only take the first argument. The other argument doensn't works. Here are the URL
http://111.222.333.444/MicroStrategy/servlet/mstrWeb?Server=******&Project=*****&Port=0&evt=4001&src=mstrWeb.4001&reportID=226F3C76422512B0E56995939C230DF1&visMode=0&reportViewMode=1&valuePromptAnswers=12^11
The microstrategy only takes the first argument.
Using elementsPromptAnswers generate the same result, only the first prompt receive the value
http://111.222.333.444/MicroStrategy/servlet/mstrWeb?Server=****&Project=***&Port=0&evt=4001&src=mstrWeb.4001&reportID=226F3C76422512B0E56995939C230DF1&visMode=0&reportViewMode=1&elementsPromptAnswers=F9365CA24CFDFD394F3D01ACB4EA5F21:1;474209F94C5C6140979F31848D01E40F:2
Using objectPromptAnswer generate the same result
http://111.222.333.444/MicroStrategy/servlet/mstrWeb?Server=****&Project=****&Port=0&evt=4001&src=mstrWeb.4001&reportID=226F3C76422512B0E56995939C230DF1&visMode=0&reportViewMode=1&objectsPromptAnswers=474209F94C5C6140979F31848D01E40F~12~DistChl
I've read the documentation carefully for each step by step. What I'm missed out? Is there any configuration on server side to accept all argument / parameters?
Thanks in advance.
We had did the thing you talk about using the next url:
mstrWeb?port=0&evt=2048001&src=mstrWeb.2048001&documentID=YOURDOCUMENTID&valuePromptAnswers={&Prompt1&}^{&Prompt2&}^{&Prompt3&}^{&Prompt4&}^{&Prompt5&}^{&Prompt6&}&promptAnswerMode=2
In the previous example, {&Prompt1&}, {&Prompt2&}, etc. are responses of a previous prompt. In your case, the url to create should be the next url:
mstrWeb?port=0&evt=2048001&src=mstrWeb.2048001&documentID=226F3C76422512B0E56995939C230DF1&valuePromptAnswers=12^11&promptAnswerMode=2
I think that your problem could be on the evt or promptAnswerMode parameters, because if these are not correctly configured it can get in troubles.
Hope that this answer solves your problem.
Greetings.

Update Json from URL

Im using Firebase to get Json from a uri that is
https://resplendent-inferno-1315.firebaseio.com/Sensor.json
When i get data works fine and if i delete is ok ..... im trying to find a way to
update data for example if i have in my url this json
{"Brand":"fat-re32","Temp":16}
and i wont to update Temp in 25 how can i do that ?
I have tried http put method but that produse json i url like these
{"-DELF648645fss68f5-56" :{"Temp":125} , "Brand":"fat-re32","Temp":16}
Can anyone give a sugestion im using java so plz show a ex in Java or a library :)

Creating a filter to check a case for a letter in a field in the json body in REST assured

I have a request in the form of json,which looks like this.
{"User":{"email":"test#test.com","FName":"fname"}}
When I try to send it via REST assured ,the U in the User is seen to change its case.i.e. changes to a lower case.
To send the request I have created my own serialized classes. The end-point is seen like this:
{"user":{"email":"test#test.com","FName":"fname"}}
but somehow it is not changing the case of the remaining fields.I don't knwo why this is happening.
I've even tried to create a filter for a request specification,but couldn't go any further with that too. I also then thought of first converting the serialized object to a gson,and then check the case of the User, still no luck.
Error I get is:
The class, User,does not match the payload object for payload.
Please note I am trying to use the service of another team,so I really don't have an access to their code-base(Although not needed).Observe the space between the first , and user in the above message, is it worth noting?
I finally got away with it by converting the object(JSON) into a JSON string/payload.
And while passing it as a form parameter,passed the string/payload.
Somehow,still couldn't figure out why the formparameter/formparam option in RESTAssured did not allow the serialized object to go through. But,anyway got around it this time.
Thanks for the suggestions all.

Getting "JSONObject["myKey"] is not a JSONArray."

I have a bit of code that has been working for years
JSONObject variableData = new JSONObject(request.getParameter("VARIABLE_DATA"));
JSONArray companies = variableData.getJSONArray("COMPANIES");
and today, I get the following error:
JSONObject["COMPANIES"] is not a JSONArray.
I have stopped the code prior to executing the getJSONArray() call and looked into variableData. Here is what I find:
{"COMPANIES":[{"COMPANY":"2"}]}
To me, this looks like a valid JSONArray to be pulled from a valid JSONObject, so I'm flummoxed and looking for help. Thanks.
your piece of code works fine when using org.json-20120521.jar. I think there is something wrong with the jar you are using.
But "COMPANIES":[{"COMPANY":"2"}] is not a valid json. Other question that I would ask is the exception reproducible? Did you get this data from exact same request that produced the exception? Is there a chance that your server got corrupted data? Try to write a unit test that covers this case and check were it takes you.

Url Encoding problem in Java and Solr

I am working in Solr and making some filter quires. One of my filter is consists of a space
for eg:- "fq=listing_type:New home"
But this is giving error. No result is comming out.
I also tried "fq=Listing_type:New+home"
This was not giving error. But no results are comming out. Event there is some xml which have thse values.
Can anyone tell me where is my error?
Here you see the schema.xml
Have you tried with fq=listing_type:"New home" ??? Why dont you index this field as "NewHome" ?

Categories

Resources