0

Open API 2.0 schema used as Invocable Apex with Flow that has been working for six months. Two days ago we started getting an error on the 200 response.

Expected declared response media type application/json, but got text/plain; charset=UTF-8 for operation get

We have a Case opened since we didn't touch the schema and barring a change by the other party (Federal Govt), then must've been a change at Salesforce but I'm hoping someone has a suggestion for how we might edit our schema now to overcome this error.

The responses which look like this in Postman used to be recognized as JSON. This is valid JSON and will format correctly if I put into an editor. (The below is public info)

{"resultCount":1,"results":[{"created_epoch":"1135112244000","enumeration_type":"NPI-2","last_updated_epoch":"1223408717000","number":"1588640692","addresses":[{"country_code":"US","country_name":"United States","address_purpose":"MAILING","address_type":"DOM","address_1":"1364 CLIFTON RD NE","address_2":"ROOM HB48","city":"ATLANTA","state":"GA","postal_code":"303221064","telephone_number":"404-686-7041","fax_number":"404-712-5731"},{"country_code":"US","country_name":"United States","address_purpose":"LOCATION","address_type":"DOM","address_1":"1364 CLIFTON RD NE","city":"ATLANTA","state":"GA","postal_code":"303221064","telephone_number":"404-686-7041","fax_number":"404-712-5731"}],"practiceLocations":[],"basic":{"organization_name":"EMORY UNIVERSITY","organizational_subpart":"NO","enumeration_date":"2005-12-20","last_updated":"2008-10-07","status":"A","authorized_official_first_name":"Jimmy","authorized_official_last_name":"Hatcher","authorized_official_middle_name":"T","authorized_official_telephone_number":"4046862983","authorized_official_title_or_position":"CFO Emory Healthcare","authorized_official_name_prefix":"Mr."},"taxonomies":[{"code":"282N00000X","desc":"General Acute Care Hospital","state":"GA","license":"044-049","primary":true}],"identifiers":[{"code":"05","desc":"MEDICAID","issuer":null,"identifier":"00000712A","state":"GA"},{"code":"06","desc":"MEDICARE OSCAR/Certification","issuer":null,"identifier":"110010","state":"GA"}],"endpoints":[],"other_names":[]}]}

The relevant path statement is:

"paths": {
    "/": {
      "get": {
        "description": "Get NPPES NPI data",
        "consumes": ["application/x-www-form-urlencoded"],
        "produces": ["application/json"],
6
  • Salesforce hasn't had a release recently, so it's probable that the API got broken on the far end somehow. If it's not too difficult, I suggest reviewing a response from the API manually in Postman or some other tool. Short of that, you'd have to change the produces line to text/plain, assign it to an in/out flow variable, then pass it to Apex for deserialization.
    – sfdcfox
    Commented Aug 24, 2022 at 14:59
  • I was curious if maybe Salesforce did a bug fix over the weekend in this area. The response I posted above is from Postman. Salesforce is reading that as text/plain but that is a complete JSON response above. Postman sees it as such. Changing to text/plain is kind of a non-starter as this is in our managed package and been fine for 6 months. Also already integrated with many flows.
    – ddeve
    Commented Aug 24, 2022 at 15:32
  • 2
    Did you check the response headers, though?
    – sfdcfox
    Commented Aug 24, 2022 at 15:42
  • 1
    ...this is why the best practice is to continuously monitor all interfaces. Google "synthetic monitoring".
    – identigral
    Commented Aug 24, 2022 at 17:10
  • The response headers does look like the issue. So I'm assuming this means that inadvertenly I think, this was changed by the other provider? It's text/plain;charset=UTF-8
    – ddeve
    Commented Aug 24, 2022 at 19:05

2 Answers 2

0

It does appear the issue was the response header was changed by the 3rd party from application/json to text/plain based on the Postman information.

-1

Just in Named Credential add new custom headers named "Accept" and with value "application/json"

1
  • 1
    No this doesn't work. Salesforce uses the response header value for the accept and expects them to match. Doesn't matter what I put if the sender is putting text/plain that's what SF will use.
    – ddeve
    Commented Apr 23 at 14:18

You must log in to answer this question.

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