Unable to set profile picture using Graph Explorer - microsoft-graph-api

I'm trying to update my profile picture using Microsoft Graph Explorer (v1.0) but I'm unable to do it, I'm always getting the following error :
An internal server error occurred. The operation failed., The file you chose isn't an image. Please choose a different file.
The problem is that the file I'm trying to update my picture with is an image inserted in the request body (a base64 representation of it, I used this site in order to get it: https://www.base64-image.de/).
I'm also using the header Content-Type with the value image/jpeg and I think that, as I'm logged, I don't need the authorization header.
The URL I'm using is: https://graph.microsoft.com/v1.0/me/photo/$value

This endpoint takes the raw image as input, not a base64 encoded version. From the documentation:
Request body
In the request body, include the binary data of the photo in the request body.
Since it isn't possible to stream a file like this using Graph Explorer, updating the photo isn't supported by Graph Explorer.

Related

Graph File Upload API - Images are getting corrupted

When I am trying to upload image using graph EndPoint then images are getting corrupted.
Endpoint - PUT https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{item_id}:/{file_name}:/content
Anything I am missing here?
SharePoint Message When trying to view uploaded (through above code)image. Tried without encoding as well. Even file name is not encoded then also its same behavior.
Note - This issue is with only images. Other files like PDF, CSV are working fine.
Changing form-data to binary solved my problem.

Not able to convert .docx file to pdf using microsoft graph api

For my project need, I need to convert MS format documents in to pdf. I started exploring microsoft graph API. For easiness I started with graph explorer(using my corporate and personal login) on https://developer.microsoft.com/en-us/graph/graph-explorer.
I have added sample document in drive and using https://graph.microsoft.com/v1.0/me/drive/root/children, I got itemId of my file.
Now, I am trying to convert it into pdf using https://graph.microsoft.com/v1.0/me/drive/items/{itemId}/content?format=pdf. But I am always getting response as Failure - Status Code 0
Anyone has an idea how to fix this issue?
Here is an attached screen shot of microsoft graph explorer
Note: I found similar problem here but it is not solved
According to your description, I assume you want to convert .docx file to pdf using Microsoft graph API.
Based on my test, we can use https://graph.microsoft.com/v1.0/me/drive/items/{itemId}/content?format=pdf.
It will return a failure response when run it in graph explore. However, when we use the develop control panel, we can get this request and response.
Location properties are in the response headers. It is the address of the converted file.
We can use this URI to review or download the document that converted.
The request URL:
https://graph.microsoft.com/v1.0/me/drive/items/{itemId}/content?format=pdf
The response may like this:

Ngx-editor "Choose Imagen"

I have installed ngx-editor, but when trying to upload an image it does not leave me and gives an error, both with "jpg" and with "png".
They are files from my local computer, and they are small in size.
From what I see in the official example, it does not stop going up either, it gives me the same error:
https://ngx-editor.stackblitz.io/
ERROR:
Imagen endpoint isn't provided or invalid
Please see this documentation page.
You need to implement your own endpoint API, which should receive the file via HTTP POST, store it somewhere then return a JSON containing the url of the file saved to your server.

Download or view the files sent as multi-part Request (PNG, PDF) through network proxy tool?

How to download or view the files sent as multi-part Request (e.g. PUT) via a software tool?
Is there any way to accomplish this with a specific tool like CharlesProxy on macOSX, to download and view files that were sent as a part of request (PUT multipart request)? I typically fix such issues by saving the file to sandbox via code changes. Ideally, need something that can be used by our QA and doesn't require any code modification.
Charles Proxy on macos is sufficient for the most dev/QA needs, such as:
Throttle network
Device debugging
Download response data
...
However, there is no option present to view or download files in HTTP request in Charles Proxy 4.x:
Charles Proxy 4.x (and earlier) allows saving response files, example pdf in this screenshot:
This can be done by editing binary file manually. It's a bit tricky, but can save the file in multipart HTTP request, without any modification to project code.
Here are the steps (verified on Charles v4.2.8 and macOS v10.12.6):
Save request. Right click a recorded HTTP request (the one that send file), and click "Save Request...". This will save the whole HTTP request in binary format.
Inspect Hex representation of request. Left click that recorded HTTP request, and click "Hex" tab of "Request" panel. This will show the binary representation of request, together with some parsed text.
Edit the saved request. Open the saved request (step 1) with editor that support binary, such as Sublime Text. Then, remove all non-image binary code according to the result of step 2. Especially, remove every bytes before (and include) the first empty line (0d0a0d0a in macOS and Windows, 0a0a in Linux), and remove the tail bytes. For example, following screenshot indicates request bytes of step 2, the selected bytes would be deleted (please note the 0d0a bytes, as this experiment is taken on Mac):
...
Save image file. Save the file after step 3 is finished. Then, append filename extension according to the Content-Type value in step 2. In this experiment, the Content-Type is image/png, so .png is appended to the filename.
That's it. You can open the xxx.png file now. It's a pure image file.
Note: this experiment only contain 1 file, but the strategy works when there are multiple file upload in request.

How to upload a file using multipart/related in postman?

I want to upload a text file to OneDrive API.I don't have any idea about multipart/related. Can any one suggest me how to put below data in postman to upload a file.
I resolved this issue.We need to provide Authorization & Content-Type in header and provide the remaining information in body as raw and select content-type as Text.

Resources