Dynamic Content and Redirection

The Xponent Graph API now supports HTTP status codes with a new "dc" extension. This means that dynamic redirects and authorization can be applied to the graph API. 

When the Xponent graph API is called with the string "/dc" at the end of the request URL then the response from the return node is interpreted in a different way. If the returned object includes a statusCode attribute then that is the code that will be returned by the Xponent Graph API. Any valid HTTP status code is allowed. 

Some of the more popular status codes: 

  • 4xx - including "401 unauthorised" if access to the particular resource is not permitted
  • 302 - redirect - this allows the response to be immediately redirected to a new location specified by a "redirectURL" field

Implementing Authorization

Your graph can use any of the input values, including header values, query parameters and body to implement an authorization scheme. If the request does not meet your authorization requirements then you can return this literal from a Return Node: 

{ 
  "body":"Unauthorised",
  "statusCode":401,
  "headers":{"x-special":"things","x-auth":"XDECTFVYGUBHJN"}
}


if the call to the graph API was of the form 

GET https://api.kitewheel.com/api/v1/listener/3a02aceea5c55eb3cdc2726c2a873c8b/dc

then the response headers should look like the below. As you can see the HTTP status code is set and the x- headers have also been set. 

< HTTP/1.1 401 Unauthorized
< Access-Control-Allow-Origin: *
< Content-Type: text/html; charset=utf-8
< Date: Fri, 01 Feb 2019 20:58:04 GMT
< ETag: W/"c-7W/48EQCx7MQfaIAfpgL92Khowc"
< x-auth: XDECTFVYGUBHJN
< x-special: things
< Content-Length: 12
< Connection: keep-alive


Dynamic Content Redirect 

A similar approach is used for dynamic redirect and here as well as providing a statusCode of 302 you should also return a redirectURL attribute. Hitting this API end point will force the browser to redirect to the specified URL. This can be used for dynamic link redirection as well as dynamic image content. 

{ 
  "statusCode":302,
  "redirectURL": "https://kitewheel.com" 
}

Privacy Policy
© 2022 CSG International, Inc.