MS Entra API Connector

DanK 0 Reputation points
2024-04-04T19:00:14.9733333+00:00

I setup an API Connector during a user signup, my api works well and everything looks good, but I am wondering how to handle errors, because I set an non existing URL and I am still able to sign up without any problem, I would expect some error during the signup if entra is not able to communicate with the connector.

Microsoft Entra
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,838 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. James Hamil 24,746 Reputation points Microsoft Employee
    2024-04-04T20:37:31.3833333+00:00

    Hi @DanK , it is possible that the API connector is failing gracefully and returning a success response even if the URL is incorrect. In this case, you may need to modify your API connector to return an error response if it is unable to communicate with the endpoint. You can add error handling logic to your API connector code by doing something like this:

    import requests
    
    def call_api(endpoint_url, auth_token):
        headers = {'Authorization': 'Bearer ' + auth_token}
        response = requests.get(endpoint_url, headers=headers)
        if response.status_code != 200:
            # Return an error response if the API call fails
            return {'error': 'API call failed'}
        else:
            # Return the response data if the API call succeeds
            return response.json()
    

    The call_api function makes a GET request to the specified endpoint URL with the provided authentication token. If the API call fails (i.e., the response status code is not 200), the function returns an error response with a message indicating that the API call failed. If the API call succeeds, the function returns the response data in JSON format.

    You can modify this code to handle other types of errors as well, such as network errors or authentication errors. More information here.

    Please let me know if you have any questions and I can help you further.

    If this answer helps you please mark "Accept Answer" so other users can reference it.

    Thank you,

    James


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.