cancel
Showing results for 
Search instead for 
Did you mean: 

401 Unauthorized - Build Apps Unable to Access BTP Destination API

depratihari
Explorer
0 Kudos
678

Hi Experts,

I am facing strange error while calling SAP Build process automation from SAP Build apps using SAP Build apps published library API integration in which i have published my build process automation API trigger.

Performed all steps correctly in steps provided in "https://help.sap.com/docs/build-apps/service-guide/sap-build-process-automation?q=service+key".

When i debugged the issue i found the error as below

"{
"status": 401,
"statusText": "Unauthorized",
"headers": {
"cache-control": "no-cache, no-store, max-age=0, must-revalidate",
"expires": "0",
"pragma": "no-cache",
"referrer-policy": "no-referrer",
"www-authenticate": "Bearer error=\"invalid_token\", error_description=\"Jwt token with allowed audiences [destination-xsappname!b62, uaa, openid, xs_account, sb-clone850d95a770d2421f962aa985e61e9bda!b107153|destination-xsappname!b62] matches none of these: [xsuaa!b120249]\", error_uri=\"https://tools.ietf.org/html/rfc6750#section-3.1\"",
"x-content-type-options": "nosniff",
"x-frame-options": "DENY",
"x-vcap-request-id": "70a2438e-ac45-4a98-4696-cf9c0fa58649",
"x-xss-protection": "0",
"date": "Sun, 12 Jan 2025 09:18:37 GMT",
"strict-transport-security": "max-age=31536000; includeSubDomains; preload;",
"connection": "close"
},
"responseText": ""
}

Any help will be appreciated.

 

Accepted Solutions (1)

Accepted Solutions (1)

Dan_Wroblewski
Developer Advocate
Developer Advocate

This is my destination ... notice the URL is only the base endpoint.

Dan_Wroblewski_0-1736835371523.png

These 4 videos shows you the entire process of triggering process from SAP Build Apps, from beginning to end. But if you are failing from Postman, then it would seem something else is wrong, since he destination is not involved there.

Trigger Process from SAP Build Apps #1 (free projects)

 

 

Trigger Process from SAP Build Apps #2 - Retrieve Instances

 

 

Trigger Process from SAP Build Apps #3 - Retrieve Process Attributes

 

 

Trigger Process from SAP Build Apps #4 - Cancel, Suspend, Resume Instances

 

 

depratihari
Explorer
0 Kudos
Thanks Dan For your inputs. I changed Authentication Type to "OAuth2JWTBearer" also I found I missed one step of adding the Destination in the Destination section of SAP Build control Tower. Its working as expected now. But one important thing is in SAP Help Documentation" https://help.sap.com/docs/build-apps/service-guide/sap-build-process-automation?q=service+key%22" its clearly mentioned to set authentication type must be set as "OAuth2ClientCredentials" so I followed SAP provided steps
Dan_Wroblewski
Developer Advocate
Developer Advocate

ClientCredentials will work, but the metadata showing who started the process will be the Build Process Automation service itself; with JWTBearToken or UserTokenExchange you then know who triggered he process.

I do not see anything about adding the destination to the Control Tower in that documentation topic. Where did you see it?

Dan_Wroblewski
Developer Advocate
Developer Advocate

IMPORTANT: I think what confused me is that you were connecting to SPA the "old way" and the documentation you referenced, though still valid, is somewhat superseded by the "new" way: https://help.sap.com/docs/build-apps/service-guide/processes

There are new flow functions that make connecting much easier and less error prone.

Dan_Wroblewski_0-1736846620502.png

 

Answers (1)

Answers (1)

Dinu
Active Contributor

Configure the destination sap_process_automation_service_user_access as (exactly as) described in Configure SAP Build Process Automation Destinations | SAP Help Portal

Notes:

1. Authentication Type

Authentication: OAuth2JWTBearer

2. Don't add additional property

forwardAuthToken: true

 

depratihari
Explorer
0 Kudos
Thanks Dinu for your Inputs. I changed Authentication Type to "OAuth2JWTBearer" also I found I missed one step of adding the Destination in the Destination section of SAP Build control Tower. Its working as expected now
VaradBhagwat
Explorer
0 Kudos

Hi, I'm getting 401 unauthorized error while calling Build Workflow API trigger from my SAPUI5 application (both locally running or from Build workzone). The URL called is "https://spa-api-gateway-bpi-us-prod.cfapps.us10.hana.ondemand.com/workflow/rest/v1/workflow-instance..." to get X-CSRF token. My Workflow created as per tutorial https://developers.sap.com/tutorials/spa-academy-run-salesorderprocess.html#fb19e3da-bee0-4477-afc4-... Can you suggest what is the possible resolution for this issue.

What is the correct URL to trigger the BPA workflow API from the SAP UI5 app. And what is the correct method to call the API ?

1. Calling SBPA Workflow API to trigger process from SAPUI5 app

VaradBhagwat_0-1738034344958.png

2. 401 unauthorized error -

VaradBhagwat_1-1738034345408.png

3. CORS issue while testing UI5 app locally or from Build Workzone

VaradBhagwat_2-1738034345407.png