Search code examples
restcomm

Send SMS with RestComm-Connect Issue


I tried to send SMS using restcomm http api, it was successful when sent with Media_Type="application/x-www-form-urlencoded" from SOAPUI.

But while trying it with "application/json" it throws following error

01:00:22,439 SEVERE [com.sun.jersey.spi.container.ContainerRequest] (http-/127.0.0.1:8080-1) A message body reader for Java class javax.ws.rs.core.MultivaluedMap, and Java type javax.ws.rs.core.MultivaluedMap<java.lang.String, java.lang.String>, and MIME media type application/json was not found.

The registered message body readers compatible with the MIME media type are:
*/* ->
  com.sun.jersey.core.impl.provider.entity.FormProvider
  com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider
  com.sun.jersey.core.impl.provider.entity.StringProvider
  com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
  com.sun.jersey.core.impl.provider.entity.FileProvider
  com.sun.jersey.core.impl.provider.entity.InputStreamProvider
  com.sun.jersey.core.impl.provider.entity.DataSourceProvider
  com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
  com.sun.jersey.core.impl.provider.entity.ReaderProvider
  com.sun.jersey.core.impl.provider.entity.DocumentProvider
  com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReader
  com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader
  com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader
  com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
  com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
  com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General
  com.sun.jersey.core.impl.provider.entity.EntityHolderReader

From documents it look like only Response could be XML or JSON.

Two Questions:-

  1. To get response in JSON we have to use URL ends with .json, same can be achieve by setting "Accept=application/json" header. Any specific reason to use URL approach?

  2. Why JSON request not supported?

    • application/json enter image description here

    • application/x-www-form-urlencoded enter image description here


Solution

  • Thanks for your question Imran,

    • Answer to your first question is that, twilio came first and defined the api, we, in order to try to be compatible with them, adopted the same api approach. We can say it is not as per core principles of rest/httpbut one can say it is easier for a web developer to put .json instead of playing with headers but that a different debate. I hope I already covered reason to use URL approach.

    • For second question, it makes sense to support json requests. (Would you like to open a github issue for that, would you be interested to contribute on it.)