Unable to add user to app via Merge passthrough request

I can add a user to an app through the API via Postman and the Oktakit ruby gem. When performing what should be the same request through Merge, it returns a 400. Other Merge passthrough requests are working, it’s just the POST to {{url}}/api/v1/apps/{{appId}}/users that’s not working.

Request:

payload = {
  method: "POST",
  headers: {
    Accept: "application/json",
    ContentType: "application/json"
  },
  path: "/api/v1/apps/#{@okta_app_id}/users",
  data: {
    id: @okta_user_id || "",
    scope: "USER"
  }
}
response = api_instance.passthrough_create(access_token, payload)

Response:

{:errorCode=>"E0000021",
 :errorSummary=>"Bad request.  Accept and/or Content-Type headers likely do not match supported values.",
 :errorLink=>"E0000021",
 :errorId=>"oaew11VolvfReORLaZtMdGS2A",
 :errorCauses=>[]}

It’s not the suggested issue of Accept and/or Content-Type. Here’s the request headers in the MergeHRISClient object:

 #<MergeHRISClient::RemoteResponse:0x000000010d600de8
 @headers=
  {:"User-Agent"=>"Mozilla/5.0",
   :"Accept-Encoding"=>"gzip, deflate, br",
   :Accept=>"application/json",
   :Connection=>"keep-alive",
   :Authorization=>"<redacted>",
   :ContentType=>"application/json",
   :"Content-Length"=>"47",
   :"x-datadog-trace-id"=>"15018062895474666192",
   :"x-datadog-parent-id"=>"15035386594106804400",
   :"x-datadog-sampling-priority"=>"1"},
 @method="POST",
 @path="/api/v1/apps/<app-id>/users",
  ...
>

Calling .to_json on the body has the same effect. I’ve compared working Postman requests to the Merge <=> Okta request and I don’t see any real difference.

I’ve also tried other content types but I haven’t been able to get this call to work if it’s coming from Merge. I’ve tried the Merge API Tester and I’m getting the same error.

Found the error. The header needs to be “Content-Type” and not “ContentType” :person_facepalming:

1 Like

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