Events
Microsoft 365 Community Conference
May 6, 2 PM - May 9, 12 AM
Skill up for the era of AI at the ultimate community-led Microsoft 365 event, May 6-8 in Las Vegas.
Learn moreThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
For some requests, you might want to respond with binary data like documents or images.
In Dev Proxy, you can define a binary response by setting the response.body
to a string value that starts with @
followed by file path relative to the current working directory, for example:
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.24.0/mockresponseplugin.schema.json",
"mocks": [
{
"request": {
"url": "https://graph.microsoft.com/v1.0/users/*/photo/$value",
"method": "GET"
},
"response": {
"body": "@picture.jpg",
"headers": [
{
"name": "content-type",
"value": "image/jpeg"
}
]
}
}
]
}
When you call GET https://graph.microsoft.com/v1.0/users/ben@contoso.com/photo/$value
, you get the image stored in the picture.jpg
file in the current directory.
Caution
If you're using the command line to execute the HTTP request, ensure that you have correctly escaped the dollar
sign. See Why is proxy not mocking my binary response.
Learn more about the MockResponsePlugin.
See also the related Dev Proxy samples:
Dev Proxy feedback
Dev Proxy is an open source project. Select a link to provide feedback:
Events
Microsoft 365 Community Conference
May 6, 2 PM - May 9, 12 AM
Skill up for the era of AI at the ultimate community-led Microsoft 365 event, May 6-8 in Las Vegas.
Learn moreTraining
Module
Access user photo information by using Microsoft Graph - Training
Learn how to create a custom JavaScript application to retrieve user photo information by using Microsoft Graph.