0

This is similar to How to use HTTP Callout action in Flow with body of Content-Type: application/x-www-form-urlencoded

I am trying to create an HTTP callout for a flow. The service I am calling is older and defaults to an XML response unless you add Accept application/json to the header.

The only way to do that is to edit the external service's json descriptor. But when I try to save my changes I am told that the ext service cannot be updated because it's referenced in a flow. that creates a catch-22 because I cannot edit the ext service but if I remove the callout from the flow to edit it, I can no longer reference the updated external service from a new callout, because each callout has its own external service.

it appears that new versions of the service can be created to overcome this but I don't see that options. https://help.salesforce.com/s/articleView?id=release-notes.rn_forcecom_ext_services_update_a_schema.htm&type=5&release=238&_ga=2.17265338.2030904402.1692615330-540034750.1669830930 i can make a copy and edit that.

any ideas how to allow me to edit an external service to add this to the header and maintain my existing callout?

2
  • because each callout has its own external service : how did you arrive at this conclusion?
    – identigral
    Commented Oct 25, 2023 at 4:00
  • 1
    Apologies if my language was inexact. when you create an http callout it creates an external service. you can also create an external service directly. however, I have not found a way to take an existing external service and assign that to a new http callout in flow. (perhaps this can be done with callouts in other areas.) if you know of a way to do this, that would likely solve the issue.... Ah, i now see that the external services are available as actions in Flow! Commented Oct 25, 2023 at 5:24

1 Answer 1

0

I have an answer, that I hope will be helpful to others. I realize now that the premise of my question was somewhat faulty.

I am new to External Services in SF. I didn't realize they could be created directly and not simply as a byproduct of creating an HTTP Callout via Flow. I also didn't realize that once you had created an External Service, you could add it to any flow simply by adding an Action and selecting the External Service. (I was trying to create an HTTP Callout and then linking that to an existing External Service, which is not possible.)

My underlying issue is that I am dealing with a legacy REST API service that originally only accepted and returned XML. That is still the default, but if you include Accept application/json in the header, the call will return JSON.

That posed a problem because the External Service expects a JSON response. (Perhaps there is a way to build it from scratch to expect XML?) I assumed I needed a way to manually update the OpenApi schema in the External Service to "force" the inclusion of the Accept header in the request. Perhaps it is possible to do that, but none of the OpenAPI documentation provided a solution.

Instead, the solution was for the schema to support an XML response in the response/content section. Here is an example (I truncated some of the schema, so this may not be valid JSON):

    "responses": {
      "2XX": {
        "description": "",
        "content": [

          {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "parent": {
                    "type": "string"
                  }
                }
              }
            }
          },

          {
            "application/xml": {
              "schema": {
                "type": "object",
                "properties": {
                  "parent": {
                    "type": "string"
                  }
                }
              }
            }
          }
        ]

Now when I call the action in the Flow, the XML response does not throw an error.

My flow is only looking for the response code, not retrieving any information from the response itself. It's not clear whether the flow can extract information from the XML response. From my initial testing I am not able to do that, but I suspect I am doing something wrong and that this is possible.

You must log in to answer this question.

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