Exporting data via an OData API
I am experiencing issues while attempting to retrieve data from multiple Cornerstone OnDemand (C SOD) API views using Azure Data Factory.
The process works seamlessly on Postman, but when implemented in ADF, I encounter authentication and request errors. Below are the detailed steps I have taken, configurations used, and the errors received.
Objective:
Create an ADF pipeline that retrieves data from multiple CSOD API views using OAuth2 authentication and store the data in a designated sink.
Views to Access:
"vw_rpt_applicant",
"vw_rpt_applicant_interview_management",
"vw_rpt_applicant_response",
"vw_rpt_culture",
"vw_rpt_custom_field_value_local",
"vw_rpt_forms2_submissions",
"vw_rpt_language",
"vw_rpt_offer_letter",
"vw_rpt_onboarding",
"vw_rpt_ou",
"vw_rpt_ou_cf",
"vw_rpt_ou_custom_field_text_response_local",
"vw_rpt_ou_title_local",
"vw_rpt_ou_type",
"vw_rpt_performance_review",
"vw_rpt_performance_review_competency_sections",
"vw_rpt_performance_review_goal",
"vw_rpt_performance_review_question",
"vw_rpt_performance_review_response_comment",
"vw_rpt_performance_review_section",
"vw_rpt_performance_review_sign_off",
"vw_rpt_performance_review_step",
"vw_rpt_recruiting",
"vw_rpt_recruiting_hold_status",
"vw_rpt_requisition",
"vw_rpt_requisition_approver",
"vw_rpt_requisition_cf",
"vw_rpt_requisition_posting",
"vw_rpt_resume",
"vw_rpt_smp_task_review",
"vw_rpt_succession_incumbent_smp_cf",
"vw_rpt_succession_incumbent_smp_cf_cs",
"vw_rpt_succession_successor",
"vw_rpt_succession_successor_smp_cf",
"vw_rpt_succession_successor_smp_cf_cs",
"vw_rpt_succession_task",
"vw_rpt_task_local2",
"vw_rpt_task_status_local2",
"vw_rpt_task_step_local",
"vw_rpt_tnu_areas_of_interest",
"vw_rpt_user",
"vw_rpt_user_cf",
"vw_rpt_user_dynamic_relation",
"vw_rpt_user_groups",
"vw_rpt_user_ou",
"vw_rpt_user_ou_history",
"vw_rpt_user_ou_info",
"vw_rpt_user_ou_status",
"vw_rpt_user_relation_type_local",
"vw_rpt_user_social_feedback",
"vw_rpt_user_status",
"vw_rpt_user_status_local",
"vw_rpt_review_template_local",
"vw_rpt_review_template_type_local"
Steps Taken:
- Created an Array Parameter ('EntityNameList') with all of the views listed above.
- Created a Pipeline with the Following Activities:
- Web Activity ('GetOAuthToken'):
- URL: 'https://sseacademy.csod.com/services/api/oauth2/token'
- Method: POST
- Headers: 'Content-Type' : 'application/x-www-forum-urlencoded'
- Body: grant_type=client_credentials&client_id=<YourClientID>&client_secret=<YourClientSecret>&scope=all
- Set Variable Activity ('SetAccessToken'):
- Variable Name: 'AccessToken'
- Type: String
- Value: '@activity('GetOAuthToken').ouytput.access_token'
- ForEach Activity:
- Items: '@pipeline().parameters.EntityNameList'
- Inside ForEach:
- Set Variable Activity ('CurrentEntitySetUrl'):
- Variable Name: 'CurrentEntitySetUrl'
- Type: String
- Value: '@item()'
- Copy Data Activity:
- Source:
- Dataset: REST Dataset
- Base URL: 'https://sseacademy.csod.com/servic4es/api/x/odata/api/views'
- Relative URL: '@variables('CurrentEntitySetUrl)'
- Headers: 'Authorization' : 'Bearer @variables('AccessToken')'
- Sink:
- Configured to Azure Blob Storage
- Source:
- Set Variable Activity ('CurrentEntitySetUrl'):
- Web Activity ('GetOAuthToken'):
- Testing with a Single View ('vw_rpt_offer_letter'):
- Web Activity ('GetOAuthToken'):
- Configured the same as above.
- Set Variable Activity ('SetAccessToken'):
- Configured the same as above.
- Web Activity ('FetchData_vw_rpt_offer_letter'):
- URL: 'https://sseacademy.csod.com/services/api/x/odata/api/views/vw_rpt_offer_letter'
- Method: GET
- Headers: 'Authorization' : 'Bearer @variables('AccessToken')'
- Web Activity ('GetOAuthToken'):
Errors Encountered:
- Initial Attempt with ForEach Loop:
- Error: '401 Unauthorized'
- Description: The pipeline successfully retrieves the OAuth token, but fails when attempting to access the views, indicating an authentication issue.
- Testing with Single View ('vw_rpt_offer_letter'):
- Error Response: { "code": "BadRequest", "message": null, "target": "pipeline//runid/87a52c02-5c03-4163-89c3-266d6ad50b35", "details": null, "error": null }
- Description: Attempting to fetch data from 'vw_rpt_offer_letter' results in a BadRequest error with no additional details.
Troubleshooting Steps Taken:
- Verified OAuth Token Retrieval:
- Confirmed that the 'GetOAuthToken' activity successfully retrieves a token.
- Tested the same token in Postman with the GET request, and it worked as expected.
- Checked API Endpoint and Headers:
- Ensured that the URL is correctly formatted.
- Verified that the 'Authorization' header is correctly set to 'Bearer <AccessToken>'.
- Simplified the Pipeline:
- Tested with a single view to isolate the issue.
- Still encountered 'BadRequest' when accessing 'vw_rpt_offer_letter'.
- Reviewed Permissions and Scopes:
- Ensured that the OAuth token has the necessary permissions to access the specified views.
- Double-checked client credentials and scope settings.
- Compared with Postman Configuration:
- Ensured that the ADF pipeline replicates the successful Postman request configuration.
I would greatly appreciate any insights or recommendations to resolve these errors in my ADF pipeline. Thank you in advance!