cancel
Showing results for 
Search instead for 
Did you mean: 

SAC Deployments via APIs

harshgargaz
Discoverer
0 Kudos

Hello Everyone

Within our project, we are trying to create automated deployment pipelines via Jenkins on SAC, to move the content (Models and Stories) across environments.

I went through below links and created relevant API calls using Basic Authentication:

https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/14cac91febef464dbb1efce20e3f1613/3ccfab3348dd407db089a...

https://community.sap.com/t5/technology-blogs-by-sap/sap-analytics-cloud-apis-getting-started-guide/...

We created a sequential workflow and executed the API workflow using Postman from Windows and were successful in transporting content across tenants.

Steps followed are as below : 

1.  Configure a Client under App Integration in the Administration area with all acceses.

2. Get access token :

3. get Stories and Models

4. Create post request and pass the Authentication header and XS-CSRF token from previous API

5.  Do an Export Job from Source tenant

6. Run/Execute the Import Job in target tenant using Job ID from step 5 

ABove steps were successful when we did it manually from Postman, but when we tried the same using Curl Commands from Linux server based Jenkins, we are failing at Step 4 with the error:  XS-csrf token not valid.

Tried manually passing the above mentioned token from linux server and still didnt work.

Our Network Environment:  1. There is an IAFA proxy (Internet access proxy)

2. No proxy used to connect to SAC from Postman

Please find below Curl Commands for connection to API and the error message in screenshot attached.

Looking forward for some valuable feedback here.

### Step 1: get access token
curl --location --request POST "${SAC_AUTH_URL}/oauth/token?grant_type=client_credentials" --header "Authorization: Basic ${SAC_AUTH_TOKEN_PSW}" >${TOKEN_RESPONSE_JSON}
We get a proper return, so we can extract $SAC_ACCESS_TOKEN

### Step 2: get stories and models
curl -s -D ${SAC_RESPONSE_HEADER} -x ${USE_PROXY} --location --request GET "${SAC_API_URL}/stories?include=models" --header "Authorization: Bearer ${SAC_ACCESS_TOKEN}" --header "x-sap-sac-custom-auth: true" --header "x-csrf-token: fetch" >${SAC_RESULT_FILE}
Access works fine, we get a json file with the stories and models
we can extract $CSRF_TOKEN from the responsheader by grep "x-csrf-token:"

 

### Step 3: request export job with CSRF token and SAC_ACCESS_TOKEN
curl -D ${SAC_RESPONSE_HEADER} --location "${SAC_API_URL}/content/jobs" --header "x-sap-sac-custom-auth: true" --header "x-csrf-token: ${SAC_CSRF_TOKEN}" --header "Content-Type: application/json" --header "Authorization: Bearer ${SAC_ACCESS_TOKEN}" -d @${JOB_EXPORT_JSON} >${SAC_RESPONSE_FILE}
access is denied

Error Message: 

{"timestamp":"2024-03-25T12:19:13.902+00:00","status":403,"error":"Forbidden","path":"/api/v1/content/jobs"}

x-csrf-token: Required
x-frame-options: DENY

Br

Harsh Garg

 

Accepted Solutions (0)

Answers (0)