Odata 4.0 and JSON format

Hello Teams,

i'm building an Integration in Appian 19.3 which is supposed to pass some process variables to the uipath orchestrator. The body request is like

{
"itemData": {

"Priority": "Normal",
"Name": "myOrchestratorqueue",
"SpecificContent": {

"name@odata.type": "#String",
"name": ri!variable,
"name2@odata.type": "#String",
"name2": ri!variable2,
"name3@odata.type": "#String",
"name3": ri!variable3,
....
}
}
}

My problem is that some of these variables are array type and my process, which calls the integration via smart service, can't pass them properly to the integration itself. An error message like "bad request" or "unespected array when trying to read json" is always returned. When i test the integration manually i can pass only quoted strings. How can i set the body request properly, if possible, for passing arrays? I can't find the right namespace for arrays in odata.type. I tried to use square brackets unsuccessfully. Many thanks for helping me.

  Discussion posts and replies are publicly visible

Parents
  • This should be valid JSON, but I'm wondering if it doesn't match what the service is expecting. Do you have a sample request that works for this server that you could post? I think your best bet is to see what the expected request looks like and craft your request to match. You might also need to use a!fromJson() and a!toJson() to see how Appian performs the conversions between the dictionary format and JSON. Keep in mind that Appian's dictionary format is very similar to JSON, but it isn't exactly the same (especially for arrays). For instance, if you provide this as your request body in the integration

    {
        "itemData": {
    
          "Priority": "Normal",
          "Name": "myOrchestratorqueue",
          "SpecificContent": {
    
            {"name@odata.type": "#String",
            "name": "test"}, 
            {"name@odata.type": "#String",
            "name": "test2"},
            {"name@odata.type": "#String",
            "name": "test3"}
          }
        }
      }

    Appian then converts it to JSON that looks like this:

    {
        "itemData":{
            "Priority":"Normal",
            "Name":"myOrchestratorqueue",
            "SpecificContent":[
                {"name@odata.type":"#String","name":"test"},
                {"name@odata.type":"#String","name":"test2"},
                {"name@odata.type":"#String","name":"test3"}
            ]
        }
    }

    That's why having the expected JSON request will help you. Once you have this expected request, create an expression rule and test a!fromJson() and plug in your sample JSON as a rule input. Then, set up your dictionary to match that format.

  • Hello mr Lewis and many thanks for replying so fast! Thanks for suggestions, i'll build an expression rule to test.

    This is a sample that works:

    {
    "itemData": {

    "Priority": "Normal",
    "Name": "PEC_Orchestrator",
    "SpecificContent": {

    "Recipient@odata.type": "#String",
    "Recipient": "mail@provider.com", 
    "CarbonCopy@odata.type": "#String",
    "CarbonCopy": "theirmail@provider.com",
    "object@odata.type": "#String",
    "object": "task nr 123",
    "body@odata.type": "#String",
    "body": "see attachments",
    "Attachments@odata.type": "#String",
    "Attachments": "C:\root\folder\filename.extension"

    }
    }
    }

    If I need to append more than a single value to every string, separated by quotes and commas as odata expects, i receive the error. Anyway i'll try until the right format. Maybe i can't fine a namespace for odata arrays because this data type is not supported. Thanks again.  

  • If you want an array of multiple items (e.g. show multiple items for the recipient), try this:

    "itemData": {
    
        "Priority": "Normal",
        "Name": "PEC_Orchestrator",
        "SpecificContent": {
    
          "Recipient@odata.type": "#String",
          "Recipient": {"mail@provider.com", "mail2@provider.com", "mail3@provider.com"}, 
          "CarbonCopy@odata.type": "#String",
          "CarbonCopy": "theirmail@provider.com",
          "object@odata.type": "#String",
          "object": "task nr 123",
          "body@odata.type": "#String",
          "body": "see attachments",
          "Attachments@odata.type": "#String",
          "Attachments": "C:\root\folder\filename.extension"
    
        }
      }

Reply
  • If you want an array of multiple items (e.g. show multiple items for the recipient), try this:

    "itemData": {
    
        "Priority": "Normal",
        "Name": "PEC_Orchestrator",
        "SpecificContent": {
    
          "Recipient@odata.type": "#String",
          "Recipient": {"mail@provider.com", "mail2@provider.com", "mail3@provider.com"}, 
          "CarbonCopy@odata.type": "#String",
          "CarbonCopy": "theirmail@provider.com",
          "object@odata.type": "#String",
          "object": "task nr 123",
          "body@odata.type": "#String",
          "body": "see attachments",
          "Attachments@odata.type": "#String",
          "Attachments": "C:\root\folder\filename.extension"
    
        }
      }

Children
  • Peter it worked!! I had to put braces inside double quotes, but multiple values came to orchestrator queue! That's it:

    {
    "itemData": {

    "Priority": "Normal",
    "Name": "myQueueOrchestrator",
    "SpecificContent": {

    "Recipient@odata.type": "#String",
    "Recipient": "{mail1@provider.com, mail2@provider.com}",
    "CarbonCopy@odata.type": "#String",
    "CarbonCopy": "{mail3@provider.com, mail4@provider.com}",
    "object@odata.type": "#String",
    "object": "task 17530409",

    "mailbody@odata.type": "#String",

    "mailbody": "see Attachments",
    "Attachments@odata.type": "#String",
    "Attachments": "{C:\root\folder\filename1.extension, C:\root\folder\filename2.extension}"

    }
    }
    }

     Thank you so much for helping me!!!!