Jump to content

curl API HTTP/1.1 400 Bad Request


Recommended Posts

Posted

Hi

 

For a couple of days I have been trying to find out how to refresh a certain tv show in emby with the use of scripts.

The script calls curl to send a POST request to emby to refresh a certain show:

I use:

curl -v -X POST -d '"{"TvdbId":"274431"}"' --header "Content-Type:application/json" --url "http://localhost:8096/Library/Series/Added?api_key=c85dd79392504ad6b7f2bc9f5a25f7ca

though I get this as response then

Note: Unnecessary use of -X or --request, POST is already inferred.
* timeout on name lookup is not supported
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8096 (#0)
> POST /Library/Series/Added?api_key=c85dd79392504ad6b7f2bc9f5a25f7ca HTTP/1.1
> Host: localhost:8096
> User-Agent: curl/7.51.0
> Accept: */*
> Content-Type:application/json
> Content-Length: 17
>
* upload completely sent off: 17 out of 17 bytes
< HTTP/1.1 400 Bad Request
< Content-Type: application/json; charset=utf-8
< Server: Mono-HTTPAPI/1.0
< Date: Tue, 08 Nov 2016 22:44:57 GMT
< Connection: close
< Transfer-Encoding: chunked
<
{"ResponseStatus":{"ErrorCode":"SerializationException","Message":"Could not des
erialize 'application/json' request using MediaBrowser.Api.Library.PostUpdatedSe
ries'\nError: System.Runtime.Serialization.SerializationException: Type definiti
ons should start with a '{', expecting serialized type 'PostUpdatedSeries', got
string starting with: '{TvdbId:274431}'\r\n   at ServiceStack.Text.Common.Deseri
alizeTypeRefJson.StringToType(TypeConfig typeConfig, String strType, EmptyCtorDe
legate ctorFn, Dictionary`2 typeAccessorMap)\r\n   at ServiceStack.Text.JsonSeri
alizer.DeserializeFromStream(Type type, Stream stream)\r\n   at ServiceStack.Hos
t.Handlers.ServiceStackHandlerBase.CreateContentTypeRequest(IRequest httpReq, Ty
pe requestType, String contentType)"}}* Curl_http_done: called premature == 0
* Closing connection 0

Or I get a 204 No Data reply

 

Anyone know what I am doing wrong?

Posted

What version of Emby Server?

Posted

Can it be that it is an issue at emby side?  I don't see anything wrong with my JSON and it is throwing an exception

Posted

What is the version number?

Posted

Ok, thanks. I just wanted to rule out changes in beta or dev. You're on stable. I'm not sure off the top of my head what the issue is, but perhaps just try putting the value on the query string instead of a json body.

Posted (edited)

Sending a GET to /Library/Series/Added?api_key=e471e2b4059c4a998b4fa75ec97625e7&TvdbId=274431 results in a HTTP/1.1 404 Not Found

 

EDIT

 

as it needs to be a POST, I have tried sending POST request with no data, but that also returns the HTTP/1.1 204 No Content error

Edited by WesDW
Posted

I will try updating to beta version, hope that helps Since i still haven't fixed the error.

Posted

Yea I'm sorry, ultimately something about your request needs to be corrected and I just don't have the availability right now to get to the bottom of that myself. For starters i would look through the wiki on the API and make sure that request guidelines are being followed:

 

https://github.com/MediaBrowser/Emby/wiki/Authentication

Posted

I have fixed it and it is working now!

Thanks for the help

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...