Search code examples
restjitterbit

Jitterbit - How to capture Response header (Location) from redirect URL


I am calling Bullhorn REST API's OAuth Endpoint to get the Authorization Code. However, On calling the endpoint, Bullhorn redirects it to another endpoint which returns code within URL of redirected endpoint.

In Postman, within settings, when I disabled option Automatically follow redirects I was able to capture the code of redirected URL within Response Header's Key - Location.

However, In Jitterbit with Http v2 connector I am not able to capture response header Location or anything related to redirected URL. Its only returning standard response and headers of the called endpoint.

I have attached screenshot of Postman and Jitterbit. Postman HTTV2 Connection HTTV2 GET

Can someone please help me to understand how this can be done in Jitterbit via Connector/Script (latter if its even possible)

Thanks!

cc: @Ashavan

UPDATED

HTTV2_OAuth2

Bullhorn REST API OAuth

UPDATE 2

As Ashavan rightly mentioned in his comment, Bullhorn docs, they don't support a client credentials or password grant type, so the built-in OAuth support in the Jitterbit's HTTPv2 won't work.

So I tried to use No Auth in HTTPV2 Connection as shown below UPDATED HTTPV2 CONNECTION SETTINGS

And in HTTPV2 GET, Passed the required Query Parameters which I have passed in Postman as shown below

UPDATED HTTPV2 GET

Connected jitterbit script to HTTV2 GET to read headers, but got no value NOTE: Tried both $jitterbit.target.http.response.header.Location; and $jitterbit.source.http.response.header.Location;

SCRIPT TO CAPTURE HREADER

Added transformation post script and did Mirror source schema and auto map.

Transformatio_Toread_http response

Finally printed the values mapped using a Variable below is the response I got

Messages logged in post-transformation scripts

code->
Bullhorn_APIAuthorizationResponse->{
  "response": {
    "responseItem": {
      "status": true,
      "properties": null,
      "headers": [
        {
          "key": "server",
          "value": "nginx/1.22.1"
        },
        {
          "key": "date",
          "value": "Wed, 01 May 2024 03:50:47 GMT"
        },
        {
          "key": "content-type",
          "value": "text/html"
        },
        {
          "key": "content-length",
          "value": "306"
        },
        {
          "key": "last-modified",
          "value": "Wed, 09 Nov 2022 13:52:34 GMT"
        },
        {
          "key": "etag",
          "value": "\"636bb0a2-132\""
        },
        {
          "key": "accept-ranges",
          "value": "bytes"
        }
      ],
      "responseContent": "<!DOCTYPE html>\n<html>\n<head>\n<title>Welcome to Bullhorn!</title>\n<style>\nhtml { color-scheme: light dark; }\nbody { width: 35em; margin: 0 auto;\nfont-family: Tahoma, Verdana, Arial, sans-serif; }\n</style>\n</head>\n<body>\n<h1>Welcome to Bullhorn</h1>\n<p>Thank you for using Bullhorn</em></p>\n</body>\n</html>",
      "error": {
        "statusCode": null,
        "details": null
      }
    }
  }
}

As you can see in the above output unlike Postman, I do not get response headers (Location) of the redirected URL, its just printing headers of the base URL.

Complete Jitterbit operation

Jitterbit Operation


Solution

  • It seems you're trying to capture the authorization code in the OAuth 2.0 handshake. The HTTPv2 connector supports OAuth authentication to where you shouldn't need to deal with all of that. You can simply set up the connector to use the endpoint you ultimately plan to call and include the necessary authorization settings in the connector.

    You would set the Authorization field to OAuth 2.0 and additional options will open up to enter the needed details. From your screenshot, it would appear you need a grant type of Password Grant to allow a username and password to be entered. More details available here.