RESTful service in Uniface

Author: knut.dybendahl@gmail.com (Knut)

Hi all, I need to put a REST/json service together - and here's the problem; The .NET application is sending a requestheader with application/json and of course the json string. Sometimes we get 2 fields, sometimes 10. There is no notation in the JSON as to which table / entity to use - it only contains the field names - which coincidentally doesn't match to any of our entity fields. Upon receiving this in Uniface, $webinfo("INPUT") is empty. Ok, thought of switching to a DSP - nah, webload needs to have the JSON structure built in the component - ain't gonna happen. My understanding (and testing using $webinfo("DATA") - nothing happens. In finishing, if the request is sent as a content-type:text/plain, I do get text/plain="{"field1":1, "field2":"yes".........}" via $webinfo("INPUT") and can do a jsontostruct and manipulate the json that way So, do I need to (despite the fact I don't want to) - define an entity with the names of the input members as the field names to get this to work? Is this the only / best way of doing this - or does anyone else have a better way of doing this when sender insists on using content-type=application/json? BTW - I've tried using a SVC, DSP, USP and a FRM with public operation... on 9.6.08 Knut

3 Comments

  1. Hi Knut, is the JSON string sent with the request perhaps something like a "named" parameter list? Perhaps somewhere one can get a documentation of the contracts or expeced processing which gives a better understanding to populate a form with all the parameter names as optional fields so you can receive all the different requests?


    Author: ulrich-merkel (ulrichmerkel@web.de)
  2. Knut said In finishing, if the request is sent as a content-type:text/plain, I do get text/plain="{"field1":1, "field2":"yes".........}" via $webinfo("INPUT") and can do a jsontostruct and manipulate the json that way So, do I need to (despite the fact I don't want to) - define an entity with the names of the input members as the field names to get this to work? Is this the only / best way of doing this - or does anyone else have a better way of doing this when sender insists on using content-type=application/json? BTW - I've tried using a SVC, DSP, USP and a FRM with public operation... on 9.6.08 Knut  

    Hi Knut, The WRD only supports the MIME-Type application/json since version 9.7.02. For details see Issue 31157 (Support for MIMEType application/json is missing). So, when you use version >= 9.7.02 then $webinfo("INPUT") will contain data when using content-type=application/json. Hope this helps. Daniel


    Author: diseli (daniel.iseli@uniface.com)
  3. Hi Daniel, Indeed, that explains it! Thank you. Knut


    Author: Knut (knut.dybendahl@gmail.com)