I am trying to use Named Credential for Marketing Cloud Transactional Messaging API. And I am having issues sending SMS.
I was able to setup an External Credential: Authentication Protocol = OAuth 2.0 Authentication Flow Type = Client Credentials with Client Secret Flow
And I was able to authenticate using the Client Id and Client Secret. Please see below:
NAMED_CREDENTIAL_REQUEST NamedCallout[Named Credential Id=xxxx, Named Credential Name=MCCredential, Endpoint=https://mcls-xxx.rest.marketingcloudapis.com/messaging/v1/sms/messages/xxx-xxx, Method=POST, External Credential Type=EXTERNAL, HTTP Header Authorization=Method: Bearer - Credential: xxx, Content-Type=application/json;charset=UTF-8, Request Size bytes=296, Retry on 401=True]
However, I could not send an SMS.
See that status is 404:
02:08:27:165 NAMED_CREDENTIAL_RESPONSE NamedCallout[Named Credential Id=xxx, Named Credential Name=MCCredential, Status Code=404, Content-Type=application/json; charset=UTF-8, Response Size bytes=134, Overall Callout Time ms=1137, Connect Time ms=1
I believe the access token received is not enough because I needed(not required) the account_id for the request as per documentation. https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/access-token-s2s.html#access-token-return
Using Custom Setting to set the credentials with account_id is working fine.
callout request for accesstoken -> callout send sms using the accesstoken
I also tried removing the account_id with this approach and I got the same error. So I'm quite sure that this issue is caused by the missing account_id on the credential.
Is there a way to pass the account_id or somewhat override the authentication in the external credential? I want to use the named credential to avoid 2 callouts and to completely remove the custom setting.
Note: I don't have the visibility on the MC side and have no experience on MC. I probably need to reach out to them.