Page 1 of 1

Rest API - enctype & rawexpr

Posted: Thu Apr 28, 2016 8:20 pm
by vikas
Hi Plum

I have a requirement to invoke a REST API for which both request & response have a format as "application/json".
Relevant section of WADL from REST API is pasted below.

In order to implement it I am using <data> tag and setting enctype as "application/json" but still I am getting error as "Unsupported encoding type: application/json".
Does Plum support this encoding? Please let me know.

Also let me know what value I need to use for "rawexpr" attribute.
An Example will be great. Thanks a lot.
------
<resource path="card/order/activationRequest">
<method name="POST">
<request>
<representation mediaType="application/json"/>
</request>
<response>
<representation mediaType="application/json"/>
</response>
</method>
</resource>
------

Re: Rest API - enctype & rawexpr

Posted: Fri Apr 29, 2016 9:13 am
by support
Hi Vikas,

Unfortunately, "application/json" is not yet a supported encoding type for <data> tag responses. For the moment, only requests can be encoding using json. JSON responses are a feature that is in the pipeline for the next release of our platform, but we do not yet have a release date estimate for this version.

For now, our recommendation is that you use a server-side scripting language such as PHP to interact with your REST API and its JSON responses.

Regards,
Plum Support

Re: Rest API - enctype & rawexpr

Posted: Fri Apr 29, 2016 10:58 am
by vikas
Thanks for reply.

Please let me know the response type that is supported by Plum at this point.

Also let me know am I right using "enctype" for JSON request. or is there some other attribute that I need to set for JSON request?
How is 'rawexpr' attribute used?

Re: Rest API - enctype & rawexpr

Posted: Fri Apr 29, 2016 3:39 pm
by support
Hi Vikas,

At this point, only XML responses are supported by the data tag.

When submitting json data, you will want to set three things:
  • method="raw"
    enctype="application/json"
    rawexpr="{some expression evaluating to a json string}"
Here is an example:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.1">
  <form>
    <var name="submitData" expr="'{"id": 1, "passcode": "2245"}'" />
    <data name="responseData" src="validateRestService.xml" method="raw" enctype="application/json" rawexpr="submitData" />
    <block>
      Hello <value expr="responseData.documentElement.firstChild.toString()"/>.
    </block>
  </form>
</vxml>
Here the rawexpr is pointing to a variable that contains the data in json format as a string.

Regards,
Plum Support