Forum Discussion

Kelemvor's avatar
Kelemvor
Icon for Expert rankExpert
9 months ago
Solved

Powershell: Expanding a variable inside single quotes to make an API call

Hi, I’m trying to use Powershell to make an API call and pass in the SDT start/end time as a variable.  However, because the call has to be within single quotes, I can’t get it to expand the variabl...
  • Dave_Lee's avatar
    9 months ago

    It might be easier to build up the body of your API call in a variable and then pass it in.  So something like this:

    $body = '{"sdtType":1,"type":"DeviceSDT","deviceId":13771,"startDateTime":’ + $now + ‘,"endDateTime":’ + $later + ‘}'

    Then use the $body variable in your API call.

    Dave