Home > database >  Passing object list as URL parameters
Passing object list as URL parameters

Time:03-24

I want to pass Boxes object list as query parameters into URL. For example:

[
{
    "text": "One does not simply",
    "x": 10,
    "y": 10,
    "width": 548,
    "height": 100,
    "color": "#ffffff",
    "outline_color": "#000000"
},
{
    "text": "Make custom memes on the web via imgflip API",
    "x": 10,
    "y": 225,
    "width": 548,
    "height": 100,
    "color": "#ffffff",
    "outline_color": "#000000"
    }
]

I have no idea how can I do it so I tried something like this but it didn't work.

https://api.imgflip.com/caption_image?template_id=615795&username=dssfdfd&password=sdssfs&text0=hjfdksl&max_font_size=30&boxes=[ 
{
    "text": "One does not simply",
    "x": 10,
    "y": 10,
    "width": 548,
    "height": 100,
    "color": "#ffffff",
    "outline_color": "#000000"
},
{
    "text": "Make custom memes on the web via imgflip API",
    "x": 10,
    "y": 225,
    "width": 548,
    "height": 100,
    "color": "#ffffff",
    "outline_color": "#000000"
    }
]

Any idea how to do it? Thanks for any help.

CodePudding user response:

your query string for array of boxes should be like this, Notice that " # " are removed from the colours property since they usually interfere with a result. You can add them back at API side.

boxes[0].text=One does not simply&boxes[0].x=10&boxes[0].y=10&boxes[0].width=548&boxes[0].height=100&boxes[0].color=ffffff&boxes[0].outline_color=000000&boxes[1].text=Make custom memes on the web via imgflip API&boxes[1].x=10&boxes[1].y=225&boxes[1].width=548&boxes[1].height=100&boxes[1].color=ffffff&boxes[1].outline_color=000000
  • Related