Maybe this is the wrong place to ask, but maybe somebody has successfully done this.
I try to call a REST API of one of my servers using Powershell. The call gets correctly processed on the server but I cannot see the results, e.g. the ResponseDTO
. This is my PS script:
$request = @{
PlatformId = 3308668551
BizBusApplicationIntegrationKey = "TopalAccounting-728270854"
ActivatingUserName = "Joe Doeeeee"
}
$Url = "http://172.16.63.241:6083/bbopman/platform/confirmtopalserverregistration"
(Invoke-RestMethod -Method Post -Uri $Url -Body $request).model
The challenge is the last line. If I simply call Invoke-RestMethod -Method Post -Uri $Url -Body $request
it retuns a html page with about 10000 characters. Inside this page I can find my response object as JavaScript…
Does anybody know how I get the output correctly as JSON object??
For those who are interested: I got it working with a Bash
script. Instead of curl
(I consider it as very user-unfriendly…), I use a tool called httpie which makes calling REST services from Linux command line or bash scripts extremely easy! Here my bash code: (replace --verbose
with --body
to just get the response DTO as JSON data, --verbose
is good for debugging only!)
#!/bin/bash
url="172.16.63.241:6083/bbopman/platform/confirmtopalserverregistration"
http --verbose POST $url \
PlatformId=3308668551 \
BizBusApplicationIntegrationKey=TopalAccounting-728270854 \
ActivatingUserName=='Joe Doe'
And the result (just test data, don’t waste your time trying keys and passwords… )
POST /bbopman/platform/confirmtopalserverregistration?ActivatingUserName=Joe+Doe HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 92
Content-Type: application/json
Host: 172.16.63.241:6083
User-Agent: HTTPie/0.9.4
{
"BizBusApplicationIntegrationKey": "TopalAccounting-728270854",
"PlatformId": "3308668551"
}
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Wed, 20 Jun 2018 19:53:05 GMT
Server: Kestrel
Set-Cookie: ss-id=WcEVPk9s7NoQWvwOn9Zf; path=/; samesite=lax; httponly
Set-Cookie: ss-pid=xMJ5iGNv1ulIPgwHmtWh; expires=Sun, 20 Jun 2038 19:53:06 GMT; path=/; samesite=lax; httponly
Transfer-Encoding: chunked
Vary: Accept
X-Powered-By: ServiceStack/5.02 NETStandard/.NET
{
"applicationIntegrationKey": "TopalAccounting-728270854",
"applicationName": "TopalAccounting",
"bizBusApiKey": "sYN9JgZMEzObtRTZ3-HPjwcoJSVpz_9u",
"platformId": 3308668551,
"platformName": "testmüller",
"rabbitMqPassword": "dTYiVeZpyaMe",
"rabbitMqUserName": "TopalAccounting-3308668551",
"rabbitMqVhost": "topacc"
}
If anybody could give me a hint regarding the Powershell version I would greatly apreciate!