-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raw response promises #141
Comments
@luisrpfigueiredo Refer: Getting Raw Response |
Thank you for the swift reply. Is there any estimate on when this release might be? |
I don't have the exact ETA for this, as we have more stuffs lined up before next release. I can assure you that before end of this month. |
Fixed in v1.5.2. |
@luisrpfigueiredo - did you get this working with 1.5.2 or later? I'm on 1.6 and I still get an empty response.headers. |
Hi @dancampbell691 Can you share me the code that you have used to make a request ? |
hi @muthurathinam. Here's the promise-based version. This successfully returns the raw response which includes the 202, but the headers array of the response object is empty. If I don't include the .responseType part, then the response is just an empty string. As I noted above, Chrome Network tab shows the response headers including location. res = await graphClient
.api(`drives/${this.driveId}/items/${this.attachment.FileId}/copy`)
.responseType(ResponseType.RAW)
.version('beta')
.post(
{
"parentReference": {
'driveId': this.destinationDriveId,
'id': this.destinationStoreGraphProperties.id
}
, 'name': `test ingest doc${this.$moment().format('HH-m-s')}.pdf` // temp add time so no name conflict
});
console.log(res); Any ideas would be appreciated. Thanks! |
@dancampbell691 The returned raw response is of this type. So when you do console.log the headers and body won't get printed along with the response object. you have to use one of the body methods to read the body and headers methods to work with headers. Basically, you have to use |
@muthurathinam - Thanks! res.headers.get('location') did the trick. It would be helpful if there were an example in the documentation that showed the entire flow of a copy, both the client call for the copy itself, then getting the location from the response, and calling the location url. |
@dancampbell691 Sounds valid, let me update the doc showing a smiliar flow which helps in working with raw response. 😊 |
When accessing the graph API response, we can pass a third option to the callback function in order to be able get a raw response, granting access to the headers.
Is there a way to do so through promises? If not, it would be nice to have, as using callbacks is... painful. A potential solution would be to have a .setResponseType('raw') or similar option available.
Edit: I found the .responseType functionality. Passing in MicrosoftGraph.ResponseType.RAW, or the hardcoded string "raw" is not working. Has this been implemented yet? ResponseType.RAW is not defined.
For reference, I'm trying to get the location header of the graph response after accessing the /items/{itemId}/copy endpoint. I know the request is successful because the items are being copied, just the response is always undefined.
The text was updated successfully, but these errors were encountered: