|Re: How to post JSON with the Lyo RestClient? [message #1798729 is a reply to message #1798637]
||Fri, 23 November 2018 10:43
Registered: May 2016
May I ask what is your case for using JSON? To follow-up on that, do you know that OSLC v2 servers only support a quite specific kind of JSON and only v3 servers MAY support JSON-LD?
Now onto your next question how to use Lyo Client to send JSON. In any case, to generate conformant data we use special helpers. This means you cannot use a JsonObjectBuilder from Java EE but instead have to follow Jad's example and pass CT_JSON instead of CT_RDF.
Offtopic: it escapes me why do we have two OSLCConstants classes with identical names both in core and client libs.
Does this help you with your question, Ralph?
Finally, we are trying to consolidate all OSLC-related discussion on https://forum.open-services.net/ and you are welcome to post new questions there.
Eclipse Lyo project lead & OSLC Core TC voting member
|Re: How to post JSON with the Lyo RestClient? [message #1798746 is a reply to message #1798741]
||Fri, 23 November 2018 13:21
| Ralph Schoon
Registered: November 2018
the simple truth is, that this is an internal API I was able to find looking at the web browser messages. I have captured the format it uses. I have confirmed with development that there is no OSLC compatible API for this activity.
Since I am using the OSLC4J client, I want to use that for this API as well, if possible. I have found a way and will try to look into a more compatible way with using annotations maybe. At the moment I am passing the JSON as string and read the JSON as inputfile back from the response.
I think, and I think this is going to be common, I am 'abusing' OSLC4J for all my REST calls and not only OSLC. As long as there are plenty of APIS that are not OSLC compliant I have to use, it appears to be a valid approach, if I can make it work.
This mode of working also requires sometimes to sneak in custom headers. I am using an HttpRequestInterceptor to 'massage' the headers and to add custom headers where I can not pass the header directly e.g. in create calls.
Even for some of the RDF data that comes back the resolution does not work (missing type) and I have to parse the RDF model.
I am not complaining, I am glad it works for me so far. I am just learning. I will try to publish what I learn in my blog https://rsjazz.wordpress.com/ or in our articles on Jazz.net. Maybe that helps people to get started.
The answers are definitely helping. The constants are a bit confusing, because there are so many duplicates. 8)
[Updated on: Fri, 23 November 2018 13:22]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01992 seconds