How to configure use of access token and API key in a linked service

A C (BI) 0 Reputation points
2024-09-17T22:03:04.67+00:00

Authorization and x-api-key headers have been added to linked service for connection to C365 cloud service. Can't understand reason for error. Please help

{ "errorCode": "2200", "message": "Failure happened on 'Source' side. ErrorCode=RestCallFailedWithClientError,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Rest call failed with client error, status code 403 Forbidden, please check your activity settings.\nResponse: {"message":"''eyJ........_vnPfQ'' not a valid key=value pair (missing equal-sign) in Authorization header: 'Bearer 'eyJ........_vnPfQ''."}\n,Source=Microsoft.DataTransfer.ClientLibrary,'", "failureType": "UserError", "target": "Get entitytypes", "details": [] }

User's image

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,997 questions
{count} votes

3 answers

Sort by: Most helpful
  1. AnnuKumari-MSFT 33,401 Reputation points Microsoft Employee
    2024-09-18T07:42:43.82+00:00

    Hi A C (BI) ,

    Welcome to Microsoft Q&A platform and thanks for posting your query here.

    It seems that the error you're encountering might be due to the issue with the format of the Authorization header. The key issue is the access token being passed dynamically, but it’s not properly formatted within the Bearer token in the header.

    The error message indicates that there’s an issue with the token string, particularly missing or misplaced parts of the Authorization header format:

    1. Ensure that the Authorization header is in the format:
       Authorization: Bearer <access_token>
    
    1. Check the dataset parameters where the access token is passed to ensure that the token is correctly retrieved and concatenated with the Bearer prefix.
    2. If you're using dynamic content, ensure the expression generating the header looks like this:
     @concat('Bearer ', dataset().accessToken)
    
    This will concatenate the "Bearer " prefix with the actual token.
    
    1. Verify that the access token is valid, unexpired, and correctly obtained before the request is made.
    2. Please ensure all the permissions are in place to access the REST API.

    Hope it helps. Kindly let us know how it goes.

    0 comments No comments

  2. A C (BI) 0 Reputation points
    2024-09-19T14:42:13.4033333+00:00

    Discovered the issue and it is so frustrating but the Base URL for specified in the Dataset/linked service just needed a forward slash on the end of it '/' !!!

    Obviously then, I removed the forward slash from the relative URL.

    The error message wasn't that great but shout out to Annu for trying to help. And you are right - a lot of people forget the space after Bearer :)

    0 comments No comments

  3. AnnuKumari-MSFT 33,401 Reputation points Microsoft Employee
    2024-10-03T05:52:18.8566667+00:00

    Hi A C (BI) ,

    Thankyou so much. Glad that you figured out the way to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Adding forward slash (/) at the end of the Base URL helped in resolving the issue

    Kindly accept the answer by clicking on Accept answer button so that the solution reaches the community in case anyone is facing similar issue. Thankyou.


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.