Closed robinmalik closed 3 years ago
Performing the test locally with Invoke-WebRequest
and I'm seeing it's being returned in quotes:
HTTP/1.1 200 OK Content-Length: 119 Content-Type: application/json Date: Sat, 25 Jul 2020 15:37:55 GMT Server: Microsoft-HTTPAPI/2.0
"Validation: Testing client application reachability for subscription Request-Id: 7df11aaa-75a8-41b2-8a61-4dc86cd9751b"
Perhaps that's the problem?
So you are getting back more than expected? (Sorry on my phone right now)
If so, are you writing the value out in the script you are executing? If so trim it down to just the value you expect, see if that works, you may need to Add Out-Null to the end of the logging line.
No worries, please take your time!
I've found the culprits - would have helped if I'd read the headers of the IWR too. Using a couple of POSTMAN tests by Microsoft it's showing it failing due to both the content type and the return body.
Do we have a way to modify this with native functionality in the module or would it require some substantial modification? I appreciate this is a REST module so returning application/json is 'as it should be' :)
I may be confused. In the module I believe I attempt to set it to Json. Before sending the response back. I'd have to take a closer look.
I'm open to any changes to the module, that's why it's open source! It should ideally work for everyone!
$script:Response.ContentType = 'application/json'
That's hard coded in the 'invoke-StreamOutput' function
It does set it to JSON. A quick and dirty hack of Invoke-StreamOutput
to remove that and I managed to get it working, though working it into the module itself will be a bit of work. I'll have a think! I use Gitlab all the time but I think this would be my second or third time trying to propose changes here. Will re-familiarise myself with the process :)
Sounds good looking forward to see what you come up with.
The updated module has been pushed to the Gallery! https://www.powershellgallery.com/packages/RestPS/7.0.32 - Let me know how it goes.
Thanks! I'll test it soon.
Hi,
Firstly, thanks for this awesome module.
Unfortunately I've hit an issue trying to use this to respond to a POST request with the following conditions:
This is from https://docs.microsoft.com/en-us/graph/webhooks#notification-endpoint-validation
I've tried parsing the POST args and returning the "validationToken" part only (though it doesn't look like a normal token because it includes descriptive text). Server console output is:
2020-07-25 16:22:57 INFO: Start-RestPSListener: Processing RequestType: POST URL: / Args: validationToken=Validation%3a+Testing+client+application+reachability+for+subscription+Request-Id%3a+f639c33c-aa24-4f37-a065-ded6210a44dd
I've tested a local query to ensure the correct part of the query string is returned and decoded, but when I initiate it from MS, the response moans with
Subscription validation request failed. Response must exactly match validationToken query parameter.
.The full server response is this:
Any ideas?
Thanks!