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)

Comments

  • Are you asking for advice on how best to structure the JSON or are you asking for advice on how best to implement the JSON structure you already have in mind? Or a little of both? It feels like a little of both to me which means I'm not sure how to respond in the best way because one issue affects the other.

    Let's start with the structure of the JSON. Could you display an example of what this might look like?
  • I'm asking how to do it at all. I want to add schema, and I want to add link relations and I do not know how to do either of those things
  • Thank you for the clarification. Perhaps you've already seen both of these articles, but in order to avoid repeating what has already been written, can you look at these and let me know if they help?

    How do I add hypermedia to a resource?

    How do I add hypermedia controls to a resource?
  • ok, that explains that b is as simple as I was hoping it would be. I can just add more links there in the same way that the example code was but point to other resources.

    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.
  • 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.
  • Yeah, I think most of the questions I was asking were answered by spending a lot of time on reddit today. We were hoping to have a schema that was referenced so users could understand the data they were looking at when they did a GET, but its decoupled making it less useful since you cannot reference it.

    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.
  • 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.


    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.
Sign In or Register to comment.