0

I have been following the instructions provided in the official salesforce developer docs here regarding importing mulesoft apis using sfdc external services for use in a flow. I have followed the instructions to the letter, exactly as they are described and ultimately when attempting to hit the api recieve a "301 - Moved Permanently" response.

For some info, not sure what is relevant and what isn't:

  1. The api is running on a Cloudhub worker in a non-prod environment, and we have a DLB and VPC configured

  2. The external service, named credential, and flow are all configured in a dev sandbox environment.

  3. One thing I attempted was to change the URL in the named credential to the actual endpoint for my mule api (https://nonprod-api.myorg.com/example-api-name-dev/api/v1), instead of https://anypoint.mulesoft.com, just to see if anything changes. Interestingly, the error response changes to "PKIX path building error; no valid certificate found for build path". I switched back to https://anypoint.mulesoft.com, but the fact the error changes may suggest my 301 problem lies with the named credential.

Ultimately I am a little confused why following a walkthrough exactly step by step as it is described leads to this error; this almost suggests to me there is some kind of custom browser configuration on my side that I am not aware of causing some kind of redirect. I have attempted to inspect network traffic with console and wireshark to get some indication of whats happening when I debug the flow and get 301, but haven't been able to see anything unusual.

Edit: I have also ensured the api is working properly by testing the endpoint with postman and receiving a successful response. Everything is working properly on the Mulesoft side.

4
  • It could be an issue between Mulesoft and your service. The first step would be to debug this in Mulesoft. If you've done so, please edit your question and provide more detail.
    – identigral
    Commented Apr 25, 2022 at 17:08
  • 1
    It doesn't seem the request ever reaches Mulesoft, or to put another way the request never reaches the api endpoint URL. That's why I wanted to ask in sfdc forums first. I would have nothing to debug in Mulesoft, no events are logged in either the platform audit trail or the api logs themselves. The "service" I am using is sfdc external services and configured according to their own documentation. Commented Apr 25, 2022 at 17:13
  • If you're sure that the request never reaches Mulesoft, then Named Credential or Mule/SF integration is a likely culprit. This is a fairly complex setup so our recommendation is to open a support case.
    – identigral
    Commented Apr 25, 2022 at 17:17
  • Alright cool - I already have a support case open with salesforce so hopefully they are able to help troubleshoot. I'll also triple check I don't see any incoming requests to either mule platform or api itself. Thanks. Commented Apr 25, 2022 at 17:20

3 Answers 3

1

For future reference here, I set up debug logs on myself and was able to find an issue with the named credential. Check out step 5 official sfdc documentation on setting up a named credential here: https://help.salesforce.com/s/articleView?id=sf.external_services_mulesoft_create_named_credential.htm&type=5. Step 5 instructs you to set up the named credential with URL https://anypoint.mulesoft.com. However, when I run the flow leveraging this ext. service/named cred and look at the debug logs, it looks like the external service combines my imported api endpoint (in this case /ping) with this URL such that the request is made to https://anypoint.mulesoft.com/ping. Here is the actual entry, note the Endpoint:

 09:25:25.57 (57193873)|NAMED_CREDENTIAL_REQUEST|NamedCallout[Named Credential Id=0XA0v0000018Tcj, Named Credential Name=muleCredTakeTwo, Endpoint=https://anypoint.mulesoft.com/ping, Method=GET, External Credential Type=EXTERNAL, HTTP Header Authorization=Method: Bearer - Authorization Credential Hash: 000000000, Content-Type=application/json; charset=UTF-8, Request Size bytes=-1, Retry on 401=True]

This is NOT the URL I need to make requests to. The url where the application is running looks like https://nonprod-api.mycompany.com/app-name-dev/api/v1/ping. I have not found the correct way to configure the URL as the official sfdc documentation is clearly missing something, however this is the source of the 301 error so this is the immediate answer to my issue.

0
0
  1. Based on your comment above, the Named Credential URL should be: https://nonprod-api.mycompany.com/app-name-dev/api/v1

  2. The error you received above at the beginning, "PKIX path building error; no valid certificate found for build path", refers to the fact that you are trying to connect to an HTTPS endpoint, but that you have not setup a signed certificate on that end.

Once you get a signed cert in your mulesoft API build path, so that it can support HTTPS calls, this error should go away.

0
  1. I found it not so clearly mentioned in the documentation, while reading the lines twice or thrice will then make you understand but not the beginners it will confuse them and they will open this page.
  2. So what I found and implemented Mulesoft's Anypoint Platform with Salesforce is that you need to create 2 named credentials
  3. The first one is for Integrating Mulesoft's Anypoint Platform and the other one is for calling the API
  4. When we import the API using the Anypoint Platform's named credential it will import the method But over there while importing we have to specify another named Credential as well since we need the url of the api
  5. For eg. if I have an api in Mulesoft such as https://salesforce.com/createOpportunity The first step will only create an invocable action for /createOpportunity I need to also specify where the /createOpportunity resource should hit
  6. For this case I need to also create another named credential for 'https://salesforce.com/' Hope this helps you !If yes Please upvote

You must log in to answer this question.

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