Exporting data via an OData API

A K 0 Reputation points
2024-09-03T11:07:57.1066667+00:00

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:

  1. Created an Array Parameter ('EntityNameList') with all of the views listed above.
  2. Created a Pipeline with the Following Activities:
    1. Web Activity ('GetOAuthToken'):
      1. URL: 'https://sseacademy.csod.com/services/api/oauth2/token'
      2. Method: POST
      3. Headers: 'Content-Type' : 'application/x-www-forum-urlencoded'
      4. Body: grant_type=client_credentials&client_id=<YourClientID>&client_secret=<YourClientSecret>&scope=all
    2. Set Variable Activity ('SetAccessToken'):
      1. Variable Name: 'AccessToken'
      2. Type: String
      3. Value: '@activity('GetOAuthToken').ouytput.access_token'
    3. ForEach Activity:
      1. Items: '@pipeline().parameters.EntityNameList'
      2. Inside ForEach:
        1. Set Variable Activity ('CurrentEntitySetUrl'):
          1. Variable Name: 'CurrentEntitySetUrl'
          2. Type: String
          3. Value: '@item()'
        2. Copy Data Activity:
          1. Source:
            1. Dataset: REST Dataset
            2. Base URL: 'https://sseacademy.csod.com/servic4es/api/x/odata/api/views'
            3. Relative URL: '@variables('CurrentEntitySetUrl)'
            4. Headers: 'Authorization' : 'Bearer @variables('AccessToken')'
          2. Sink:
            1. Configured to Azure Blob Storage
  3. Testing with a Single View ('vw_rpt_offer_letter'):
    1. Web Activity ('GetOAuthToken'):
      1. Configured the same as above.
    2. Set Variable Activity ('SetAccessToken'):
      1. Configured the same as above.
    3. Web Activity ('FetchData_vw_rpt_offer_letter'):
      1. URL: 'https://sseacademy.csod.com/services/api/x/odata/api/views/vw_rpt_offer_letter'
      2. Method: GET
      3. Headers: 'Authorization' : 'Bearer @variables('AccessToken')'

Errors Encountered:

  1. Initial Attempt with ForEach Loop:
    1. Error: '401 Unauthorized'
    2. Description: The pipeline successfully retrieves the OAuth token, but fails when attempting to access the views, indicating an authentication issue.
  2. Testing with Single View ('vw_rpt_offer_letter'):
    1. Error Response: {   "code": "BadRequest",   "message": null,   "target": "pipeline//runid/87a52c02-5c03-4163-89c3-266d6ad50b35",   "details": null,   "error": null }
    2. Description: Attempting to fetch data from 'vw_rpt_offer_letter' results in a BadRequest error with no additional details.

Troubleshooting Steps Taken:

  1. Verified OAuth Token Retrieval:
    1. Confirmed that the 'GetOAuthToken' activity successfully retrieves a token.
    2. Tested the same token in Postman with the GET request, and it worked as expected.
  2. Checked API Endpoint and Headers:
    1. Ensured that the URL is correctly formatted.
    2. Verified that the 'Authorization' header is correctly set to 'Bearer <AccessToken>'.
  3. Simplified the Pipeline:
    1. Tested with a single view to isolate the issue.
    2. Still encountered 'BadRequest' when accessing 'vw_rpt_offer_letter'.
  4. Reviewed Permissions and Scopes:
    1. Ensured that the OAuth token has the necessary permissions to access the specified views.
    2. Double-checked client credentials and scope settings.
  5. Compared with Postman Configuration:
    1. 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!

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,566 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.