September 30, 2021

Provide json content as URL

The usual way to pass input files to a work item is to upload them somewhere on the cloud and pass their URL to the work item.

However, you could also provide the content of a file directly (instead of uploading it somewhere first) and then design automation will generate the given file with that content on its server, so your app bundle will be able to open it and use it.

You'll find many blog posts (e.g. see "inputJson" here) and even the learnforge tutorials doing it.

You can provide the content like this for the work item:

{
  "inputJson": {
    "localName": "params.json",
    "url": "data:application/json,{\"height\":\"16 in\", \"width\":\"10 in\"}"
  }
}

Make sure you provide the localName property for such an input parameter, otherwise, design automation won't know what to name the file, and you'll get an error saying:

Value cannot be null. (Parameter 'path2').

json error

One thing to note is that there is a size limit on work item payloads, which is around 16KB. The json content you pass directly in the payload, as shown above, will be restricted by this size limit.
So if you want to send large json content, then the best thing is to handle that the usual way: upload the json file somewhere and provide its URL to the work item.

If instead of getting a file generated on the server with a given content, you just want to pass that content directly on the command line of the work item, then have a look at Pass custom command-line arguments from WorkItem

 

 

Related Posts