2

The documentation tells us that XML, however un-hip, can be used as a request format.

The reality seems to be only HTTP 415 errors with UNSUPPORTED_MEDIA_TYPE.

Class:

@RestResource(urlMapping='/zrest/*')
global class ZREST {

    @HttpPost
    global static string doPost(string obj) {
      return 'OK: '+obj;
    }
}

Request:

POST https://cs8.salesforce.com/services/apexrest/zrest.xml HTTP/1.0
content-length: 37
accept: text/xml
content-type: text/xml
authorization: OAuth ***
user-agent: Whateva
host: cs8.salesforce.com
accept-encoding: gzip

<request>
  <obj>A</obj>
</request>

Response:

<?xml version="1.0" encoding="UTF-8"?>
<Errors>
    <Error>
        <errorCode>UNSUPPORTED_MEDIA_TYPE</errorCode>
        <message>Content-Type header specified in HTTP request is not supported: text/xml; charset=UTF-8</message>
    </Error>
</Errors>

Needless to say it works fine with application/json and {"obj" : "A"}!

1
  • Did you solve this? I think the 'OK: ' is the problem. Did you try with @HttpPost global static string doPost(string obj) { return obj; }
    – Acuariano
    Dec 27, 2014 at 21:00

1 Answer 1

3

try: Accept: application/xml in your request header.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .