AnthonyMusgrove / Emby-ScripterX

Run custom external application or script (batch/bash/powershell/php/python/node.js/custom) on various events within the Emby Server.
https://emby-scripterx.com
76 stars 6 forks source link

JsonPost() sends invalid Accept header #37

Closed Slugger closed 4 years ago

Slugger commented 4 years ago

Describe the bug When using ScripterX.Web.JsonPost(), the request that gets sent includes an invalid Accept header. The header being sent in the request is:

Accept: Accept application/json

It should just be:

Accept: application/json

To Reproduce Steps to reproduce the behavior:

  1. Attempt a JsonPost() to an endpoint that enforces the Accept header content type

Endpoint will return an Invalid Media Type http error in response.

Expected behavior Proper accept header sent in request so that the endpoint can return a response

Desktop (please complete the following information): n/a

Smartphone (please complete the following information): n/a

Additional context Add any other context about the problem here.

AnthonyMusgrove commented 4 years ago

Thank you for reporting this mate, I have now fixed it. It will be available on the next release (tonight):

With a TCP listener on port 7000, I ran the following test:

ScripterX.Web.JsonPost("http://localhost:7000/hook.php", "test");

and the TCP listener now captures the correct request format:

Listening on tcp port 7000 Client connected POST /hook.php HTTP/1.1 Host: localhost:7000 Accept: application/json User-Agent: Emby Server/4.4.3.0 Accept-Encoding: deflate Content-Type: application/json Content-Length: 4

test Client disconnected

Slugger commented 4 years ago

fix is good