Skip to content

BatchResponseItem bodies contain invalid JSON #835

@GeorgeOG

Description

@GeorgeOG

Describe the bug

I am running a batch request but the body of the BatchResponseItems (a bytes object, despite the function stating it returns a BytesIO object) contains invalid JSON (it uses single quotes).

Expected behavior

Double quotes are used in all responses as per JSON standards.

How to reproduce

client = GraphServiceClient(credentials=credentials)
client.request_adapter.base_url = "https://graph.microsoft.com/v1.0"

email_batch = BatchRequestContentCollection()
for i, user_folder in enumerate(user_folders):
    user_id, folder_id = user_folder.user_id, user_folder.folder_id
    email_batch.add_batch_request_item(BatchRequestItem(
        request_information=client.users.by_user_id(user_id).mail_folders.by_mail_folder_id(folder_id).messages.to_get_request_information(),
        id=str(i)
    ))

emails_responses = await client.batch.post(email_batch)
for email_responses in emails_responses.get_responses()
    for id, response in email_responses.responses.items():
        json = json.loads(response.body

SDK Version

1.21.0

Latest version known to work for scenario above?

No response

Known Workarounds

None

Debug output

Click to expand log
<Log output here>

Configuration

No response

Other information

I cannot tell whether this is what is getting directly returned, or if it's some issue with the SDK deserialising client side - I would assume it must be client side as I can't imagine the server is returning invalid JSON.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:waiting-for-triageAn issue that is yet to be reviewed or assignedtype:bugA broken experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions