0

Need your help on this. I cannot get the right way of passing the variable to the URL. I am receiving errors.

**$SRnumber** = Read-Host "Enter SR Number"
    #144152
    $requestDescr = 
      Invoke-WebRequest 'https://test.com/api/v3/requests/**$SRnumber**?TECHNICIAN_KEY=ABCDEDFGHIJKLMNOPQRSTUVWXYZ' |
       ConvertFrom-Json  |
        Select -expand request

Error im receiving is below,

Invoke-WebRequest : {"response_status":{"status_code":4000,"messages":[{"status_code":4007,"type":
"failed"}],"status":"failed"}}
At line:4 char:3
0

1 Answer 1

1

To use interpolated strings in powershell, you need to use double-quotes:

$SRnumber = Read-Host "Enter SR Number"
#144152
$requestDescr = Invoke-WebRequest "https://test.com/api/v3/requests/$SRnumber?TECHNICIAN_KEY=ABCDEDFGHIJKLMNOPQRSTUVWXYZ" |
    ConvertFrom-Json | Select -expand request
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.