According to Whitesource document, the response headers will have
Content-Type = application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Content-Disposition: attachment; filename=<product name>.xslx
I want to extract that xslx file but, I do not know how. I've tried writing the response in a file but, all I got is is a bunch of binary characters.
Invoke-RestMethod -SkipCertificateCheck -Method Post -ContentType 'application/json' -Body $body -Uri "https://app.whitesourcesoftware.com/api/v1.3 | Out-File "abcd.csv"
I also tried to convert the response to csv before writing it, but that doesn't work either.
Invoke-RestMethod -SkipCertificateCheck -Method Post -ContentType 'application/json' -Body $body -Uri "https://app.whitesourcesoftware.com/api/v1.3 | ConvertTo-CSV | Out-File "abcd.csv"
Any idea?
After a little digging, I realized that the file is present in the
contentpart of the respose. I usedInvoke-WebRequestinstead ofInvoke-RestMethod. Here's my scripts:This will write the attached file to a file named
report.xlsx.