masp 0 Posted October 30, 2016 Share Posted October 30, 2016 (edited) Hi! I find myself having to re-create libraries quite often (I frequently re-image my server, for instance), and it's a bit painful having to add libraries manually each time. I found the (swagger) docs for api calls that I could make via (eg.) curl here (localhost): http://localhost:8096/swagger-ui/index.html but it doesn't seem to include a call to create/add a new library. Is that possible? I'm hoping for something like: curl -H "token:abcdef" -X POST -F 'name=videos' -F 'real_time_monitoring=true' http://localhost:8096/CreateLibrary but obviously happy with anything that allows me to create libraries programmatically! Thanks, Mike Edited October 30, 2016 by masp Link to comment Share on other sites More sharing options...
Luke 37067 Posted October 30, 2016 Share Posted October 30, 2016 Hi, it is possible. Unfortunately this is an area of the api that hasn't been needed heavily by others so therefore we haven't taken the time to document it fully. Therefore the best way to find out what's going on would be to review our api client libraries, which our apps use: https://github.com/MediaBrowser/Emby.ApiClient.Javascript/blob/master/apiclient.js Link to comment Share on other sites More sharing options...
masp 0 Posted October 31, 2016 Author Share Posted October 31, 2016 (edited) Thanks! Can you give me a clue as to which method to look for? Best I can guess is maybe addVirtualFolder (?). Update: in the meantime I'm trying to authenticate: following the swagger docs + some other hints, it looks like this should work: curl -X POST -d "{Username:\"mike\", Password:\"adc83b19e793491b1c6ea0fd8b46cd9f32e592fc\",PasswordMd5=\"68b329da9893e34099c7d8ad5cb9c940\"}" "http://127.0.0.1:8096/Users/AuthenticateByName?format=json" (where the passwords are hashes of the empty string, since I don't have a password) but it errors out with: {"ResponseStatus":{"ErrorCode":"ArgumentNullException","Message":"Value cannot be null.\nParameter name: username","Errors":[{"ErrorCode":"ArgumentNullException","FieldName":"username","Message":"Value cannot be null.\n"}]}} I've tried using lowercase (username) but no change. Is there a simple fix, to save my hours of experimentation? Thanks, Mike Edited October 31, 2016 by masp Link to comment Share on other sites More sharing options...
masp 0 Posted November 7, 2016 Author Share Posted November 7, 2016 (edited) I've looked at all the examples I can find, and fixed my broken md5/sha1 hashes, but I still have the same problem. This is the best I can come up with: [edited to quote the json keys] curl -X POST -H 'Content-Type: application/json' -H 'Authorization: MediaBrowser Client="testingembyclient", Device="testingembydevice", DeviceId="6c37664af595bec4424bad444f842af9e0916ab1", Version="1.0.0", UserId="4b023a683f404b63a5174f859f42bd06"' -d "{[\"Username\":\"mike\", \"password\":\"da39a3ee5e6b4b0d3255bfef95601890afd80709\",\"passwordMd5\"=\"d41d8cd98f00b204e9800998ecf8427e\"]}" "http://127.0.0.1:8096/Users/AuthenticateByName?format=json" but response is: {"ResponseStatus":{"ErrorCode":"ArgumentNullException","Message":"Value cannot be null.\nParameter name: username","Errors":[{"ErrorCode":"ArgumentNullException","FieldName":"username","Message":"Value cannot be null.\n"}]}} Any pointers will be gratefully received! I was very excited when I found emby, partly because it has such a full API, but it's frustratingly hard to get it to work! I must be doing something stupid: if anyone can point it out to me that would be great! Mike Edited November 7, 2016 by masp Link to comment Share on other sites More sharing options...
ebr 14913 Posted November 7, 2016 Share Posted November 7, 2016 Looks like a syntax error in your json (= instead of but not sure if that is the exact problem here. Link to comment Share on other sites More sharing options...
masp 0 Posted November 7, 2016 Author Share Posted November 7, 2016 (edited) Rats! Thanks! I also appended "format=json" to the url. Unfortunately neither fix gets me to a working query curl -X POST -H 'Content-Type: application/json' -H 'Authorization: MediaBrowser Client="testingembyclient", Device="testingembydevice", DeviceId="6c37664af595bec4424bad444f842af9e0916ab1", Version="1.0.0", UserId="4b023a683f404b63a5174f859f42bd06"' --data '{["username":"mike", "password":"da39a3ee5e6b4b0d3255bfef95601890afd80709","passwordMd5":"d41d8cd98f00b204e9800998ecf8427e"]}' "http://127.0.0.1:8096/Users/AuthenticateByName?format=json" Edited November 7, 2016 by masp Link to comment Share on other sites More sharing options...
Luke 37067 Posted November 7, 2016 Share Posted November 7, 2016 the best thing to do is add a library with the web app and compare the requests using the chrome debugger. And also see the api wiki if you haven't already: https://github.com/MediaBrowser/Emby/wiki Link to comment Share on other sites More sharing options...
masp 0 Posted November 7, 2016 Author Share Posted November 7, 2016 Thanks, that did the trick! I just had to remove the outer list [] in the post data (could have sworn I'd tried it both ways!!). Thanks very much for the tip: those devtools are really useful!! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now