I have implemented my own datasource in Go, which returns a JSON string. The data source is working fine and returning the correct JSON format expected by the chart (which is actually a table object to make the tests easier).
Now, I'd like to be able to use the query language features for my chart and something I could not figure out is how exactly the query language works.
Let's take the table below as example:
Name | Age | Phone
-------------------------------
John | 23 | 12341234
Chris | 47 | 54223452
Sam | 36 | 69694356
When called, my datasource will return a JSON representation of the entire table above.
In theory, I should be able to do something like this from my Javascript
query.setQuery('select Name, Age');
So, the result would ignore the column "Phone".
Now, my question is:
Is the setQuery() method applied to the JSON response only, or my datasource should be able to handle the query on request and return the correct data (only Name and Age columns). I'm not sure if the query language will act on the JSON response or if it's just an interface to tell the server what to do and the server should be able to prepare the correct data.
I'm asking that because as I said, my JSON response works fine, however the setQuery() method is being ignored. My table always shows the entire Dataset, no matter what I put on the setQuery method. Even if I define a column which does not exist, it does not cause any error.
I did some tests using a google spreadsheet and it works just fine. I should add that the structure of the JSON response from my app and the one from the google spreadsheet looks exactly the same.
Any help would be very much appreciated.
Thanks,
JB
Related
I have a source table, which receives all the fields as a space-separated string. So I am using the update policy to parse it first, do some manipulation and ingest it to the target table. But however, I am getting this error and don't know why. I have been stuck for hours, any help would really be appreciated.
.create function
UpdateFunction()
{
TempTable
| parse Record with Timestamp:datetime' 'HouseNo:string' 'Age:int' "'Adress:string'" "'Name:string'" 'Gender:string' 'CountryCode:string
| extend FullName = split(Path,"?")
| join kind=leftouter countryTable on $left.CountryCode==$right.CountryCode
| project "Admitted", Timestamp,House,Age,Adress,Country,tostring(FullName[0]),tostring(FullName[1])
}
a sample record will look like this-
20-12-2021 20B 7 "XYZ House, New York" "Anna Thomas" Female US
and my target table data should be like this
Admitted,20-12-2021,20B,21, XYZ House New York, United States, Anna, Thomas
countryTable has the country mapping to the corresponding country codes.
For next time, please include a request ID in your message. You can copy it from the web explorer using this button:
Assuming I was able to locate your requests correctly, I believe you had an extra open quotes at the end of the parse operator line, with no corresponding closing quote. I see some successful requests after that. Please reply back with a request ID if you are still experiencing the same issues.
I'm running a local server playing around with an API using Django. I have a model called 'Users' populated with a few objects, and am using DefaultRouter.
I want to know what the URL would be if I were to DELETE a specific object from this model. For example, if I wanted to GET a user with an ID of 1 in this model, the URL would be: "localhost:8000/Users/1/". What would the equivalent be to DELETE this user?
I found an explanation of this on the REST API website (below), however, I don't understand what any of the syntaxes means.
What is {prefix}, {url_path}, {lookup} and [.format]? If anyone could provide an example of what this might be using a localhost that would be really helpful.
Thanks
Let us take an example of an API (URL) to update book data with id (pk) being 10. It would look something like this:
URL: http://www.example.com/api/v1/book/10/
Method: PUT/PATCH
With some data associated.
If you want to delete you just need to change method to DELETE instead of put or patch.
Regarding your second question lets compare the url with the parameters.
prefix: http://www.example.com/api/v1/book
lookup: 10
format: It specifies what type of data do you expect when you hit the API. Generally it is considered to be json.
url_path: In general, every thing after look up except query string is considered to be url_path.
Below is the code I have now. It pulls the Job-Base-Cost just fine, however I cannot get it to pull the ID and or Name of the item. Can you help?
Link to the sites XML pull.
=importxml("link","//job-base-cost")
This is a sample of one line of the OP's XML file
<job-base-cost id="24693" name="Abaddon Blueprint">109555912.69</job-base-cost>
The OP wants to use the IMPORTXML function to report the ID and Name as well as the Job Cost from the XML data. Presently, the OP's formula is:
=importxml("link","//job-base-cost")
There are two options:
1 - One long column
=importxml("link","//#id | //#name | //job-base-cost")
Note //#id and //#name in the xpath query: // indicate nodes in the document (at any level, not just the root level) and # indicate attributes. The pipe | operator indicates AND. So the plain english query is to display the id, name and job-base-cost.
2 - Three columns (table format)
={IMPORTXML("link","//#name"),IMPORTXML("link","//job-base-cost"),IMPORTXML("link","//#id")}
This creates a series that will display the fields in each of three columns.
Note: there is an arrayformula that uses a single importXML function described in How do I return multiple columns of data using ImportXML in Google Spreadsheets?. Readers may want to look at whether that option can be implemented.
My thanks to #Tanaike for his comment which spurred me to look at how xpath works.
I'm working on a C# program that retrieves data from a ServiceNow database and converts that data into C# .NET objects. I'm using the JSON Web Service to return my data in JSON format.
What I want to achieve is as follows: If there is a relational mapping between a value (for
example: I have a table called Company, where CEO is not a TEXT field but an sys_id to a Employee Table) I want to be able to output that data not with an sys_id (or just displaying the name property by using the 'displayvariable' parameter) but by an object displayed in JSON.
This means that the value of a property should be an object in JSON instead of just a single value.
A few examples:
// I don't want the JSON like this
{"Company":{"CEO":"b181e841c9212c008aeb36850331fab2"}}
// Or by displaying the name of the sys_id table
{"Company":{"CEO":"James Henderson" }}
// I want the data as follows, so I can have all the data I need inside a single JSON record.
{"Company":{"CEO":{"name":"James Henderson", "age":34, "sex":"male", "office":"SBN Left Floor 23"}}}
From reading the documentation I couldn't find anything in the JSON Web Service that allowed me to display the information like this nor
find any other alternative. It should have something to do with joining the tables and displaying it all in the right format.
I have been using SNC for almost three years and have not found you can automatically join tables in a web service. Your best option would be to use a scripted web service which possibly takes a query parameter and table parameter. Then you can json serialized your result as you see fit.
Or, another option would be to generate a new processor that will traverse the GlideRecord object. The ?JSON parameter you pass in to the URL is merely a flag to pass your request to a particular processor. Unfortunately the OOB one I believe is a Java class not a JS script, so you would need to write a script much like I mentioned earlier to traverse the object path serializing the object graph as far down as your want to go.
I am writing some Cucumber features for my RoR app that insert records into the database then send a query to my XML API. Because of the nature of my requests (hardcoded XML) I need to know what the ID of a row is going to be. Here is my Scenario:
Scenario: Client requests call info
Given There is a call like:
| id | caller_phone_number |
| 1 | 3103937123 |
When I head over to call info
And Post this XML:
"""
<?xml version="1.0" encoding="UTF-8"?>
<request-call-info>
<project-code>1000000001</project-code>
</request-call-info>
"""
Then The call info should match
And The status code should be 0
I've got Cuke set up with my _test database, and I also noticed that it isn't resetting all of the tables prior to running my features.
What is the right way to set this up? Thanks!
Firstly, forgive me as this is going to be a bit of a brain dump, but hopefully it should help or at least give you some ideas:
You could rewrite your scenario like this:
Scenario: Client requests call info
Given There is a call with the phone number "3102320"
When I post "request-call-info" xml to "call info" for the phone number "3102320"
Then the call info for phone number "3102320" should match
And the status code for phone number "3102320" should be 0
This way you can refer to the record by an attribute that isn't the primary key.
Are you using fixtures? If so you can set the ID for the record there explicitly.
Depending on your application you might be able to run your tests using an in memory sqlite3 database.