Can anybody help me with the error I am getting upon calling the below function. Looks line an issue where it is not able to properly format the multiline graphQL String:
def verify_obs():
question_list = ["baae592c-ec9e-11e3-99de-021505f49f8a","37b5556a-b229-4010-8920-6fc72e5f629e","df3c569b-3bb7-4376-8c33-7f20603a2790","a6bfd272-aad0-4e5d-9a5e-c4a1268ea4ba","e1e9ca6a-4ceb-476e-a87c-7d591486c8da"]
my_query = '''query {
willObfuscateQuestions (questionIdList: {0}) {
questionId
state
examId
endTime
startTime
}
}'''.format(question_list)
ds_response = requests.post(
url='<end point here>',
headers={'Content-Type': 'application/json'},
json={'query': my_query}
)
response_list = ds_response.json()['data']['willObfuscateQuestions']
print(response_list)
for item in response_list:
state = item['state']
if state == 'Obfuscated' and int(ds_response.status_code) == 200:
print('Question is obfuscated')
return 0
else:
raise Exception('Obfuscation failed with response - ', ds_response.json())
Error:
Traceback (most recent call last):
File "/Users/ubhatia/Documents/RFSetup/karma-moderation-pipeline/robot-tests/KarmaModeration/Config/methods.py", line 198, in <module>
print(verify_obs())
File "/Users/ubhatia/Documents/RFSetup/karma-moderation-pipeline/robot-tests/KarmaModeration/Config/methods.py", line 49, in verify_obs
}'''.format(question_list)
KeyError: '\n willObfuscateQuestions (questionIdList'