Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
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/v1.0.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.
Next step
Learn more about the MockResponsePlugin.
Samples
See also the related Dev Proxy samples: