Json file array

Hello! I want to send a photo album via telergam api (sendMediaGroup) https://core.telegram.org/bots/api#sendmediagroup

Api requires an array of json data, indicating the type of data and the file itself, but I do not see the available parameters there. It’s impossible?

There are these additional parts in the documentation.

Have you reviewed those too?

I can perfectly send 1 file using the form.
But sending an album requires an array of json…

Sorry, I’m not following where the issue is.

My understanding of what it says is that you had an image X, you would build the JSON for that - e.g.

{
    "type" : "photo",
    "media" : "attach://<file_attach_name_X>"
}

Then if you had say two photos to put in an album, you would create the JSON in the same way and then place that into the media value as an array of JSON.

e.g.

"media" : [ {"type" : "photo", "media" : "attach://<file_attach_name_1>"}, {"type" : "photo", "media" : "attach://<file_attach_name_2>"} ]
1 Like

I can perfectly send 1 file using the form.
But sending the album requires an array of json.
I can’t make it in shorkuts

Well if I were dynamically building up the JSON I would do it as text; after all that’s all JSON really is. Text can then be passed to the Get Dictionary from Input action for parsing before you start to process individual paths within Shortcuts, but in this case you’ll just be passing it directly to the web API.

Here’s a quick shortcut that takes some example JSON as text including the arrayed example from above.

The shortcut copies the text-based JSON to the clipboard and opens it in @simonbs’ app Jayson.

In that app, we can see that it recognises the text it has been passed as JSON.

We can also see that the root level media key has an array value; which was what was required for the Telegram API.

Navigating into that key, we can see the two array entries that were defined. Note that it is a zero based index that is applied, just as in JavaScript from where JSON (JavaScript Object Notation) originates.

If we then navigate into the first array element (index 0), we can see that the object being passed in that element is once again JSON, and we can see the examples previously specified.

Does that help?

** sylumer** Thanks for the detailed answer.
But, this can be done here:

I generally know where things can be done in Shortcuts. The example I put together was purely to try and help you understand an option about creating JSON programmatically.

I also can’t tell from your response if this has addressed your underlying issue/query. If not, can you please restate the precise nature of your issue?

Not sure exactly what you are trying to show us as you just posted several screenshots in several posts, but just to my eye, and I may be wrong, but shouldn’t that second screenshot be incorporating an array?

I could do something.
To do this, add an array of Media, and inside it add a dictionary.
Inside the dictionary you can already create a key-value pair.

Sending an album only works if the media_key is given a file_id (from a previously uploaded file) or a link to a photo is transferred. Transferring files inside json in commands is not supported …