<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Problem with triggering SAP BTP Workflow from SAPUI5 application in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/problem-with-triggering-sap-btp-workflow-from-sapui5-application/qaa-p/12600412#M4725697</link>
    <description>&lt;P&gt;Hi Wiktor,&lt;/P&gt;&lt;P&gt;if you use the "api.workflow-sap" domain in Postman and e. g. get your token with a respective OAuth flow yourself, then the issue likely relates to the App router, if it works in Postman.&lt;/P&gt;&lt;P&gt;I suggest you log the data in the "error" function (or check the response body in the browser network tab). If you get the error message I mentioned (User does not have sufficient privileges), then you actually reach the workflow. Likely that isn't the case.&lt;/P&gt;&lt;P&gt;If you receive another response body (perhaps a plain "Forbidden"), then it is the app router that "blocks" you. Also check the response headers then. It might be the case that the X-CSRF-Token header has the value "Required" indicating that you do not provide a CSRF token, but the call requires one (default value of csrfProtection setting in the routes is "true"). In fact, your code above does not specify one.&lt;/P&gt;&lt;P&gt;As you say, you receive a 404 from the "bpmworkflowruntime/v1/xsrf-token" end-point. Perhaps this is because you are missing the "rest" middle path (see  bpmworkflowruntime/rest/v1/workflow-instances which you use in the other case).&lt;/P&gt;&lt;P&gt;Overall, I suppose you need:&lt;/P&gt;&lt;P&gt;- to retrieve the XSRF token from the correct URL from bpmworkflowruntime/rest/v1/xsrf-token using header "X-CSRF-Token" header with value "Fetch"&lt;/P&gt;&lt;P&gt;- to provide the returned token value in the X-CSRF-Token header of the POST call to bpmworkflowruntime/rest/v1/workflow-instances&lt;/P&gt;&lt;P&gt;Here are a few helpful links into the Guided Answers of workflow:&lt;/P&gt;&lt;P&gt;&lt;A href="https://ga.support.sap.com/dtp/viewer/index.html#/tree/2622/actions/36618:36734:37151:36739"&gt;Authorization issues on Cloud Foundry&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://ga.support.sap.com/dtp/viewer/index.html#/tree/2622/actions/36618:36734:37151:36739:37244"&gt;CSRF Token Handling on Cloud Foundry&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Additionally, knowing how to access the log of the app router helps in these cases:&lt;/P&gt;&lt;P&gt;&lt;A href="https://ga.support.sap.com/dtp/viewer/index.html#/tree/2622/actions/36618:36749:36751:37447:48412:48416"&gt;Issues integrating workflow capability with Launchpad service&lt;/A&gt; (managed app router)&lt;/P&gt;&lt;P&gt;&lt;A href="https://ga.support.sap.com/dtp/viewer/index.html#/tree/2622/actions/36618:36749:36751:37447:37543"&gt;Getting logs of standalone Application Router in the Cloud Foundry environment&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tobias&lt;/P&gt;</description>
    <pubDate>Tue, 23 Aug 2022 07:54:47 GMT</pubDate>
    <dc:creator>tobias_breyer</dc:creator>
    <dc:date>2022-08-23T07:54:47Z</dc:date>
    <item>
      <title>Problem with triggering SAP BTP Workflow from SAPUI5 application</title>
      <link>https://community.sap.com/t5/technology-q-a/problem-with-triggering-sap-btp-workflow-from-sapui5-application/qaq-p/12600409</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;I want to trigger Workflow from application by using bpmworkflowruntime destination defined on BTP.&lt;/P&gt;
  &lt;P&gt;I configured xs-app.json in application folder.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2085825-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;And here is my mta.yaml file.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2085833-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2085832-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2085829-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;In controller in function that handles the click of the button I wrote this code.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2085830-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Here is my destination.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2085831-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;The error is 403 so it seems that it calls right destination but authorization is missing.&lt;/P&gt;
  &lt;P&gt;I was working with this tutorial: &lt;A href="https://blogs.sap.com/2020/08/27/starting-workflow-from-custom-fiori-application-in-cloud-foundry/" target="test_blank"&gt;https://blogs.sap.com/2020/08/27/starting-workflow-from-custom-fiori-application-in-cloud-foundry/&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt;I also tried to call bpmworkflowruntime/v1/xsrf-token but there was 404 error.&lt;/P&gt;
  &lt;P&gt;From my understanding if I am logged in using xsuaa on SAPUI5 it should automatically authorize the destination usage.&lt;/P&gt;
  &lt;P&gt;Can someone confirm if all my configurations are correct what should I do to get it working?&lt;/P&gt;
  &lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 12:24:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/problem-with-triggering-sap-btp-workflow-from-sapui5-application/qaq-p/12600409</guid>
      <dc:creator>wskaw</dc:creator>
      <dc:date>2022-08-22T12:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with triggering SAP BTP Workflow from SAPUI5 application</title>
      <link>https://community.sap.com/t5/technology-q-a/problem-with-triggering-sap-btp-workflow-from-sapui5-application/qaa-p/12600410#M4725695</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;have you checked the calling user has suitable permissions?&lt;/P&gt;&lt;P&gt;See API docs: &lt;A href="https://api.sap.com/api/SAP_CP_Workflow_CF/resource" target="test_blank"&gt;https://api.sap.com/api/SAP_CP_Workflow_CF/resource&lt;/A&gt;&lt;/P&gt;&lt;P&gt;POST workflow-instances, 403 =&amp;gt; "User does not have sufficient privileges."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Roles permitted to execute this operation:&lt;/P&gt;
&lt;UL&gt;&lt;LI&gt;Global roles: WorkflowInitiator&lt;/LI&gt;&lt;LI&gt;Scope: WORKFLOW_INSTANCE_START&lt;/LI&gt;&lt;/UL&gt;So you should validate that the user has WorkflowInitiator role.&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tobias&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 15:05:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/problem-with-triggering-sap-btp-workflow-from-sapui5-application/qaa-p/12600410#M4725695</guid>
      <dc:creator>tobias_breyer</dc:creator>
      <dc:date>2022-08-22T15:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with triggering SAP BTP Workflow from SAPUI5 application</title>
      <link>https://community.sap.com/t5/technology-q-a/problem-with-triggering-sap-btp-workflow-from-sapui5-application/qaa-p/12600411#M4725696</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thank you for your answer.&lt;/P&gt;&lt;P&gt;I have tried calling the same API from postman and it works fine, so I think that is not a problem.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Wiktor&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 18:50:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/problem-with-triggering-sap-btp-workflow-from-sapui5-application/qaa-p/12600411#M4725696</guid>
      <dc:creator>wskaw</dc:creator>
      <dc:date>2022-08-22T18:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with triggering SAP BTP Workflow from SAPUI5 application</title>
      <link>https://community.sap.com/t5/technology-q-a/problem-with-triggering-sap-btp-workflow-from-sapui5-application/qaa-p/12600412#M4725697</link>
      <description>&lt;P&gt;Hi Wiktor,&lt;/P&gt;&lt;P&gt;if you use the "api.workflow-sap" domain in Postman and e. g. get your token with a respective OAuth flow yourself, then the issue likely relates to the App router, if it works in Postman.&lt;/P&gt;&lt;P&gt;I suggest you log the data in the "error" function (or check the response body in the browser network tab). If you get the error message I mentioned (User does not have sufficient privileges), then you actually reach the workflow. Likely that isn't the case.&lt;/P&gt;&lt;P&gt;If you receive another response body (perhaps a plain "Forbidden"), then it is the app router that "blocks" you. Also check the response headers then. It might be the case that the X-CSRF-Token header has the value "Required" indicating that you do not provide a CSRF token, but the call requires one (default value of csrfProtection setting in the routes is "true"). In fact, your code above does not specify one.&lt;/P&gt;&lt;P&gt;As you say, you receive a 404 from the "bpmworkflowruntime/v1/xsrf-token" end-point. Perhaps this is because you are missing the "rest" middle path (see  bpmworkflowruntime/rest/v1/workflow-instances which you use in the other case).&lt;/P&gt;&lt;P&gt;Overall, I suppose you need:&lt;/P&gt;&lt;P&gt;- to retrieve the XSRF token from the correct URL from bpmworkflowruntime/rest/v1/xsrf-token using header "X-CSRF-Token" header with value "Fetch"&lt;/P&gt;&lt;P&gt;- to provide the returned token value in the X-CSRF-Token header of the POST call to bpmworkflowruntime/rest/v1/workflow-instances&lt;/P&gt;&lt;P&gt;Here are a few helpful links into the Guided Answers of workflow:&lt;/P&gt;&lt;P&gt;&lt;A href="https://ga.support.sap.com/dtp/viewer/index.html#/tree/2622/actions/36618:36734:37151:36739"&gt;Authorization issues on Cloud Foundry&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://ga.support.sap.com/dtp/viewer/index.html#/tree/2622/actions/36618:36734:37151:36739:37244"&gt;CSRF Token Handling on Cloud Foundry&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Additionally, knowing how to access the log of the app router helps in these cases:&lt;/P&gt;&lt;P&gt;&lt;A href="https://ga.support.sap.com/dtp/viewer/index.html#/tree/2622/actions/36618:36749:36751:37447:48412:48416"&gt;Issues integrating workflow capability with Launchpad service&lt;/A&gt; (managed app router)&lt;/P&gt;&lt;P&gt;&lt;A href="https://ga.support.sap.com/dtp/viewer/index.html#/tree/2622/actions/36618:36749:36751:37447:37543"&gt;Getting logs of standalone Application Router in the Cloud Foundry environment&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tobias&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 07:54:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/problem-with-triggering-sap-btp-workflow-from-sapui5-application/qaa-p/12600412#M4725697</guid>
      <dc:creator>tobias_breyer</dc:creator>
      <dc:date>2022-08-23T07:54:47Z</dc:date>
    </item>
  </channel>
</rss>

