Upload a JSON File to a queue

Hello,

I want to upload a JSON file to a queue. How will I do it ?

May we ask you to be a little bit more specific. Do you want create QueueItems with the JSON or do you want add the JSON to the SpecificContent dictionary of a QueueItem?

I want to add a JSON file to a queue item

give a try on bringing the JSON to a string and add it to the specific content dictionary under a particular key or as an argument

Alright.

You cannot directly upload a file to a QueueItem.

You have a couple options

  • Stringify the JSON and add it as a Key/Value
  • Convert the File into bitecode that can be added to the QueueItem similar to the first suggestion.
  • Store the File object somewhere else (Storage Bucket in Orchestrator, File System, etc.) and store the Location reference as a Key in the Queue Item.

I don’t think QueueItems were intended to store Blobs whether they are JSON or say a binary file. Make use of your Storage Providers would be my advice.

I would also think about what it is that you want to do with the JSON. if you need to act on the JSON to make a decision, then you would be fetching and parsing the JSON each time before you could make that decision… so depending on the size and complexity it might not always make sense.

If you search the forum there has been some discussion around Uploading Attachments and Queueitems already.

1 Like

it worked. I have converted json to string and then added to queue item.
Thank you.

Perfect. we do the same als when we want store komplex datatypes or e.g. Lists. After JSONConvert.SerializeObject(theObjectVar) the resulting JSON String used in the same manner.