Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
how to add additional links and schema info
Hey all!
In using the HTTP resource services to create my JSON api information, I was thinking that I wanted to
a) provide some additional information about the field such as the type. Hopefully letting things like Power BI understand the data it is looking at.
b) add additional links to other api resources I am making for information about allowed values. ie: if a field validates against a table that I have written a different endpoint for, I would love to add a link to that endpoint so they can get valid values there.
for a), am I able to call the HTTP_JSON_RESOURCES on the object returned from a call like
objEmployees = HTTP_Resource_Services('GetObjects', Table, Filter, DisplayCols, '', '', '', '', FullEndpointURLNoQuery, '', '', 1)
or can I use the
jsonResource = HTTP_Resource_Services('GetSerializedResource', objResource)
in either case, can I add the schema information per field at this point, or does it have to be per property as it is created?
for b), is it as easy as using the existing addlinkrelations only I need something to better say "this is for this field's validation"
Rels = 'self' : @FM : 'apiEntryPoint'
URLs = FullEndpointURL : @FM : ParentURL
HTTP_Resource_Services('AddLinkRelations', objResource, Rels, URLs)
In using the HTTP resource services to create my JSON api information, I was thinking that I wanted to
a) provide some additional information about the field such as the type. Hopefully letting things like Power BI understand the data it is looking at.
b) add additional links to other api resources I am making for information about allowed values. ie: if a field validates against a table that I have written a different endpoint for, I would love to add a link to that endpoint so they can get valid values there.
for a), am I able to call the HTTP_JSON_RESOURCES on the object returned from a call like
objEmployees = HTTP_Resource_Services('GetObjects', Table, Filter, DisplayCols, '', '', '', '', FullEndpointURLNoQuery, '', '', 1)
or can I use the
jsonResource = HTTP_Resource_Services('GetSerializedResource', objResource)
in either case, can I add the schema information per field at this point, or does it have to be per property as it is created?
for b), is it as easy as using the existing addlinkrelations only I need something to better say "this is for this field's validation"
Rels = 'self' : @FM : 'apiEntryPoint'
URLs = FullEndpointURL : @FM : ParentURL
HTTP_Resource_Services('AddLinkRelations', objResource, Rels, URLs)
Comments
Let's start with the structure of the JSON. Could you display an example of what this might look like?
How do I add hypermedia to a resource?
How do I add hypermedia controls to a resource?
What about a) though. I was looking to add meta data information for a field either by adding a schema or something equivalent and I need to know how I am able to add it, and possibly where depending on the answer to how. I want to say what type of data a field is, and perhaps a title/description.
The important thing is the type as it directly affects how other systems such as Power BI will interpret the data we send them for their fancy graphs that users will make with it.
This is what I'm trying to understand better. It seems like you already have some design constraints but I don't know how that should look. I thought perhaps if you had an idea of the JSON structure in mind (even if just a rough example) I can help you figure out the best way to assemble this using the available services.
As a separate issue, are you looking to include the schema with the resource or are you looking to create a schema that would be returned separately? As you may have seen in another thread, there is a formal standard known as JSON Schema but it is decoupled from the resource content. It is retrieved from the same URL as the resource but you use the Accept header to specify application/schema+json.
We have rudimentary support for JSON Schema but it really needs some TLC to be as useful as we think it should be.
Also found that power BI does not support looking at the schema anyways, and that data types have to be defined manually for JSON files within power BI itself when you connect to a data source.
The JSON structure we had in mind was just using the standard structure the tools provide, but attach the schema, which we now know is not possible.
That's a shame. It means double the work and a very brittle system. I understand that Power BI is not trying to follow a REST architecture, but this is where REST can shine very nicely.