You should escape the curly braces in the formatted string, like so:
f'[{{"code": "orderno", "value":"{valuetarget}"}}]'
But why not let requests
format the string for you?
import requestsurl = "https://www.stie.com/api/conversations/KJQ-CZHNR-985/fields"valuetarget = "123"# 'customfields' is now a list of dictionariespayload = {'apikey': 'zbyc88srdi333d3dpq5lye48pgg1tfo1pnjvj65ld','customfields': [{"code": "orderno", "value": valuetarget}]}files = []headers = {}response = requests.request("POST", url, headers=headers, data=payload, files=files)print(response.text)