We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Rest API - enctype & rawexpr

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
vikas
Posts: 53
Joined: Wed May 13, 2015 7:46 pm

Rest API - enctype & rawexpr

Post 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>
------

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: Rest API - enctype & rawexpr

Post 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

vikas
Posts: 53
Joined: Wed May 13, 2015 7:46 pm

Re: Rest API - enctype & rawexpr

Post 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?

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: Rest API - enctype & rawexpr

Post 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

Post Reply