Legacy Dev Forum Posts

 View Only

Sign Up

  • 1.  C# Authorization Error

    Posted 06-05-2025 19:21

    78692638d4a24645fbf5 | 2020-09-17 16:15:46 UTC | #1

    Hello,

    We placed a manual call to a phone number and it’s showing up in the Developer Web API, but not in the C# client (code below). We decided to try and not use the C# SDK and make a straight POST, but it’s not quite clear how Auth is done as per the documentation. It would be great to get a sample POST so that we can get a token (we’ve only ever used the SDK). It would be even better if the SDK worked.

    var dailyConversationQuery = new ConversationQuery() { Interval = "2020-09-15T00:00:00.000Z/2020-09-16T00:00:00.000Z", };

    AnalyticsConversationQueryResponse conversationQuery = outbound.PostAnalyticsConversationsDetailsQuery(dailyConversationQuery);

    I am using the following SDK API to generate an access token:

    Configuration.Default.AccessToken = Configuration.Default.ApiClient.PostToken(clientId, clientSecret).AccessToken

    The parameters I’m passing are the clientId and clientSecret. It works for the APIs that are using the SDK. The auth error we are receiving pertains to making manual API calls and adding the configuration token to a header. The token shows a value so we’re unsure of what the issue is.

    System.FormatException: The header name format is invalid.

    This is how the header is being formatted:

    client.DefaultRequestHeaders.Add( "Authorization: Bearer" , Configuration.Default.AccessToken);

    Please advise.

    thanks! Peter


    tim.smith | 2020-09-17 16:27:08 UTC | #2

    Please refer to the authorization documentation for how to manually authorize an app: https://developer.mypurecloud.com/api/rest/authorization/use-client-credentials.html

    You can also refer to the SDK's source code to see how it's making the request: https://github.com/MyPureCloud/platform-client-sdk-dotnet/blob/master/build/src/PureCloudPlatform.Client.V2/Extensions/AuthExtensions.cs#L24.

    78692638d4a24645fbf5, post:1, topic:8844
    client.DefaultRequestHeaders.Add( "Authorization: Bearer" , Configuration.Default.AccessToken);

    This is incorrect. The header name is authorization, not authorization: bearer. That code is adding part of the header value to the name.


    system | 2020-10-18 16:27:10 UTC | #3

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 8844