REST call using XML

Hi,

I am trying to make a REST call using XML, I have it working in Postman but not with Jigx.

I am using the following code. You can test this with a dummy key and it will return a response.

In Jigx i am getting the error : [use-keg-action-callback] useExecuteActionInnerCallback() Failed to execute ‘action.sync-entities’ on ‘index’: 500 Internal Server Error The symbol “<” cannot be used as a unary operator

provider: DATA_PROVIDER_REST
method: POST
url: https://services-au.readsoftonline.com/authentication/rest/authenticate

parameters:
  x-rs-key:
      location: header
      required: true
      type: string
            
format: application/xml      

inputTransform: |
       <AuthenticationCredentials>
       <UserName>adam@laketree.com</UserName>
       <Password>x</Password>
       <AuthenticationType>SetBodyToken</AuthenticationType>
       </AuthenticationCredentials>

Any ideas?

Thanks,
Adam

Hey Adam

I believe what you are seeing is the inputTransform being parsed directly as an jsonata expression the <> characters are not escaped.

Please try something like:

inputTransform: |
       "<AuthenticationCredentials>" &
       "<UserName>adam@laketree.com</UserName>" &
       "<Password>x</Password>" &
       "<AuthenticationType>SetBodyToken</AuthenticationType>" &
       "</AuthenticationCredentials>"

Hi Bernard,

Thanks for the reply.
Unfortunately that returns the error :

use-keg-action-callback] useExecuteActionInnerCallback() Failed to execute ‘action.sync-entities’ on ‘index’: 400 Bad Request Bad Request

Did that work on your end?

Sorry I don’t have a service to test it against. I looked at the api from your code.

Initially I thought you just needed to add a content-type header.

parameters:
  x-rs-key:
      location: header
      required: true
      type: string
  content-type:
      location: header
      required: false
      type: string
      value: application/xml

But it seems that there is a bug where the content-type header is, depending on the input, overwritten or duplicated with different values.

I’ll see if we can get a fix for it

I don’t know if it helps but I was able to get authenticated using the json.

provider: DATA_PROVIDER_REST
method: POST
url: https://services-au.readsoftonline.com/authentication/rest/authenticate
useLocalCall: true

parameters:
  userName:
    location: body
    required: true
    type: string
  password:
    location: body
    required: true
    type: string
  x-rs-key:
    location: header
    required: true
    type: string

inputTransform: |
  $.{
       "UserName": userName,
       "Password": password,
       "AuthenticationType": 4
  }

outputTransform: |
  $.{
    "id": 1,
    "userName": $.inputs.userName,
    "token": $.Token
  }

Hey,

Thanks that worked. I was wondering how you got that number and found the match below.

Thanks again for your help.
Adam.