Update api body for post request using values enclosed with double quotes from python list

  Kiến thức lập trình

I am trying to call a post request using python where the body is a dictionary in which one parameter has to change based on the values of a list.

The list is as below:

my_list = ['a14mnas','ty6798h']

The body for the api call is as below:

api_body = {
"Page": 1,
"Pages": 3,
"Ids": []

}

I am trying to update the body as:

api_body["Ids"] = my_list[0]

which will update the body to

"Ids": ['a14mnas']

but i need the value in the list to be enclosed with double quotes as below:

"Ids": ["a14mnas"]

The api call takes only list with value enclosed with double quotes. How do i make the value to be in double quotes.

Tried adding ”’ + to the string but it gives a single and double quote

''' + my_list[0] + '''

LEAVE A COMMENT