Good catch! It was that extra quote mark at the end. And thanks for the tip about using lean=1.
Original Message:
Sent: Wed January 14, 2026 12:03 PM
From: Tim Ferrill
Subject: Difference in script languages
Ooh, a PowerShell question. Self-proclaimed PowerShell junkie over here.
At first glance I'd guess your problem is your URL string. You've got three quotes: two wrapping $wonum and one at the very end.
Completely possible that's just a copy/paste issue or the forum helping you out with some formatting, but I'd start by using Write-Host to get that $url printed out to make sure it looks right.
I also notice you aren't using lean=1. In general I'd recommend using that whenever interacting with the REST API.
------------------------------
Tim Ferrill
Solutions Consultant
Intelligent Technology Solutions
tferrill@webuildits.com
www.webuildits.com
@tferrill/@webuildits
Original Message:
Sent: Wed January 14, 2026 11:42 AM
From: Jason Johnson
Subject: Difference in script languages
I have the same script written in Python and PowerShell. Python works; PowerShell doesn't.
Both are making the same REST API call. It is meant to download the Work Order report with attachments. The attachments are included in the Python script, but the PowerShell script only downloads the Work Order report itself, no attachments. Is there some difference in the implementation of "Invoke-RestMethod" that changes how the call is made? I've also tried "Invoke-WebRequest" with the same results, no attachments. Is there something else to try in PowerShell? Can anyone verify this behavior in their environment?
Python:
headers = { 'Accept': 'application/PDF', 'apikey': '<apikey goes here>'}url = f'{host}/maximo/api/os/mxapiwodetail?action=genreport&reportname=woprint.rptdesign&oslc.where=wonum="{wonum}"&reportformat=pdf&attachments=1'response = requests.get(url, headers=headers, verify=False)with open(rf'{downloadPath}\{pdfFileName}', "wb") as f: f.write(response.content)
PowerShell:
$headers = @{ "Accept" = "application/PDF" "apikey" = "<apikey goes here>"}$url = $hostname/maximo/api/os/mxapiwodetail?action=genreport&reportname=woprint.rptdesign&oslc.where=wonum="$wonum"&reportformat=pdf&attachments=1"$response = Invoke-RestMethod -Uri $url -Headers $headers -Method GET -OutFile $pdfFilePath -ErrorAction Stop
------------------------------
Jason Johnson
------------------------------