I am getting error when trying to do string manipulation in a dictionary: SyntaxError: f-string: single '}' is not allowed

Viewed 42

I currently have a body of test I'm trying to pass into an API. I appear to be receiving a sytnax error: SyntaxError: f-string: single '}' is not allowed

When calling the API I have certain parameters I have to pass in the method which must be stored in a dictionary. However, in my application I have variables that need to be passed in the dictionary body that I'll pass to the API.

Similar to this using string formating with {} to specify the variables.

issue_dict = f"""{
  "projectKey": %s get_project(Teams["Dev"].value),
  "summary": " Alert for: {user_id}",
  "description": "New issue {account_id}",
  "reporter": "myname",
  "issueType": {{Teams["Config"].name}}
}""" 

After deeper research it appears this is happening because I have "()" in get_project.

I'm wondering if there's a work around for this use case. It appears the other variables work.

0 Answers
Related