Search code examples
azureazure-information-protectionmicrosoft-information-protection

Azure AIP Sync Error : profile_add_engine_async Failed with: [ConnectionHttpError] Failed sending http request with error code 'windows:87'


am trying to sync Azure AIP labels on my custom client application using AIP SDK which is implemented in cpp. For the POC I tried this example which is posted on Microsoft code example.

https://learn.microsoft.com/en-us/samples/azure-samples/mipsdk-policyapi-cpp-sample-basic/mipsdk-policyapi-cpp-sample-basic/

But it is throwing exception

    Trace   2020-01-23 16:23:58.690 telemetry_utils.cpp:66  mipsdk-policyapi-cpp-sample-basic (13592)   "Send Telemetry. Event Name : [profile_add_engine_async]
App.ApplicationId: [36980fd4-b1e8-4856-8703-c1004a99722b], Pii: [None]
App.ApplicationName: [Ravindra12], Pii: [None]
App.ApplicationVersion: [1.0.0], Pii: [None]
App.SessionId: [1], Pii: [None]
Engine.SessionId: [1], Pii: [None]
Event.CorrelationId: [c34572fd-57a9-4a97-a94b-4cf3a98518fe], Pii: [None]
Event.CorrelationIdDescription: [PolicyProfile], Pii: [None]
Event.Duration: [2.68388], Pii: [None]
Event.ErrorType: [ConnectionHttpError], Pii: [None]
Event.Failed.File: [src\upe\api_impl\policy_profile_impl.cpp], Pii: [None]
Event.Failed.Func: [mip::ProfileImpl::AddEngineAsync], Pii: [None]
Event.Failed.Line: [332], Pii: [None]
Event.Failed.Message: [Failed API call: profile_add_engine_async Failed with: [ConnectionHttpError] Failed sending http request with error code 'windows:87' Failed with: ([http_exception] 'WinHttpAddRequestHeaders: 87: The parameter is incorrect.

')], Pii: [None]
Event.UniqueId: [2029587e-eb8c-4483-a5ef-283a0a0f7a59], Pii: [None]
EventInfo.Level: [10], Pii: [None]
EventInfo.PrivTags: [33554432], Pii: [None]
MIP.Version: [1.4.154], Pii: [None]
iKey: [ce9aa5fb5a414ecebb15af10715bd8ff-831d197e-fc97-4df6-b998-c8c13a0fc3ce-6768], Pii: [None]
"   mip::WriteEventToTraceLog   29012

When debugged step by step I observed that it could successfully get the authentication token from Azure AD but not able to add PolicyEngine to PolicyProfile.

I have configured everything in Azure AIP and Azure AD as explained in the above SDK example page but still getting this error. I am not able to get what is the parameter which is invalid and what am I doing wrong.

On the other hand I could run the sample example which is using dotnet sdk. I could list all the labels. - https://learn.microsoft.com/en-us/samples/azure-samples/mipsdk-dotnet-policy-quickstart/mipsdk-dotnet-policy-quickstart/

Can someone help me to get this application running successfully.

Thank You.


Solution

  • That error will bubble up from winhttp via cpprestsdk. Based on some quick searching it seems this may happen if there's a whitespace at the end of your auth token. Can you check that?

    I just tested it out by appending a whitespace to the token, and it does reproduce the error. Based on the sample, I'm not sure why you'd get whitespace, but see if you're able to trim the end and get that to work.

    I repro'd by adding this to the auth delegate:

        string accessToken = sample::auth::AcquireToken(mUserName, mPassword, mApplicationInfo.applicationId, challenge.GetResource(), challenge.GetAuthority());
        accessToken.append(1, ' ');
    

    And it threw:

    Event.Failed.Message: [Failed API call: profile_add_engine_async Failed with: [ConnectionHttpError] Failed sending http request with error code 'windows:87' Failed with: ([http_exception] 'WinHttpAddRequestHeaders: 87: The parameter is incorrect.