Jump to content
notpiika

Question about my api http requests

Recommended Posts

notpiika

I'm trying to create a user with the API

When sending a request as follows:

POST /emby/Users/New

X-Emby-Token: xxxxxxxxxx

Name=NewUser

The call fails with "Value 'name' cannot be null" in the call to CreateUserByName

I've tried to add the same content type as web client does (form), but that doesn't work. It seems to only work when a browser is being used -- as evident when using devtools to copy a curl command to include all the headers the browser sends. However, the only one that should be required is the token one. (maybe content type too, but it seems that there's only one valid content type for this call (form), so not needed)

Tested both latest stable and latest beta, same results.

Share this post


Link to post
Share on other sites
Luke

Hi, server log?

Share this post


Link to post
Share on other sites
notpiika
6 minutes ago, Luke said:

Hi, server log?

Sorry for the picture instead of text -- can't easily copy from the large log file on my phone.Screenshot_20200816-235251.thumb.png.7279185a0bcf5ef89e9e5cde7d72667d.png

Share this post


Link to post
Share on other sites
notpiika

Fixed by setting correct content type.

Share this post


Link to post
Share on other sites
Luke

Well done.

Share this post


Link to post
Share on other sites
notpiika
Posted (edited)

Now, for the edit user endpoint:

2020-08-17 19:23:43.485 Error HttpServer: Error processing request
	*** Error Report ***
	Version: 4.5.0.18
	Command line: /mnt/mpaths/[redacted]/EmbyNET/system/EmbyServer.dll -ffmpeg /usr/bin/ffmpeg -ffprobe /usr/bin/ffprobe
	Operating system: Linux version 5.4.31-gentoo-[redacted] (root@[redacted]) (gcc version 9.2.0 (Gentoo Hardened 9.2.0-r2 p3)) #1 SMP Fri Apr 10 00:37:57 UTC 2020
	Framework: .NET Core 3.1.1
	OS/Process: x64/x64
	Runtime: opt/dotnet_core/shared/Microsoft.NETCore.App/3.1.1/System.Private.CoreLib.dll
	Processor count: 72
	Data path: /mnt/mpaths/[redacted]/EmbyNET/programdata
	Application path: /mnt/mpaths/[redacted]/EmbyNET/system
	System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
	   at MediaBrowser.Controller.Api.BaseApiService.AssertCanUpdateUser(IAuthorizationContext authContext, IUserManager userManager, Int64 userId, Boolean restrictUserPreferences)
	   at MediaBrowser.Api.UserService.Post(UpdateUser request)
	   at Emby.Server.Implementations.Services.ServiceController.Execute(HttpListenerHost appHost, Object requestDto, IRequest req)
	   at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(HttpListenerHost appHost, IRequest httpReq, IResponse httpRes, RestPath restPath, String responseContentType, CancellationToken cancellationToken)
	   at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(IRequest httpReq, ReadOnlyMemory`1 urlString, ReadOnlyMemory`1 localPath, CancellationToken cancellationToken)
	Source: MediaBrowser.Controller
	TargetSite: Void AssertCanUpdateUser(MediaBrowser.Controller.Net.IAuthorizationContext, MediaBrowser.Controller.Library.IUserManager, Int64, Boolean)

HTTP request sent (yes, simultaneous stream count is a string, that's what the web client does, too, only when updating a user though):

POST /emby/Users/[redacted] HTTP/1.1
Host: [redacted]
User-Agent: Go-http-client/1.1
Content-Length: 1815
Content-Type: application/json
X-Emby-Token: [redacted]
Accept-Encoding: gzip

{"Name":"uwu","ServerId":"[redacted]","Id":"[redacted]","HasPassword":false,"HasConfiguredPassword":false,"HasConfiguredEasyPassword":false,"Configuration":{"PlayDefaultAudioTrack":true,"DisplayMissingEpisodes":false,"GroupedFolders":[],"SubtitleMode":"Default","DisplayCollectionsView":false,"EnableLocalPassword":false,"OrderedViews":[],"LatestItemsExcludes":[],"MyMediaExcludes":[],"HidePlayedInLatest":true,"RememberAudioSelections":true,"RememberSubtitleSelections":true,"EnableNextEpisodeAutoPlay":true},"Policy":{"IsAdministrator":false,"IsHidden":true,"IsHiddenRemotely":true,"IsDisabled":false,"BlockedTags":[],"IsTagBlockingModeInclusive":false,"EnableUserPreferenceAccess":true,"AccessSchedules":[],"BlockUnratedItems":[],"EnableRemoteControlOfOtherUsers":false,"EnableSharedDeviceControl":false,"EnableRemoteAccess":true,"EnableLiveTvManagement":false,"EnableLiveTvAccess":false,"EnableMediaPlayback":true,"EnableAudioPlaybackTranscoding":true,"EnableVideoPlaybackTranscoding":true,"EnablePlaybackRemuxing":true,"EnableContentDeletion":false,"EnableContentDeletionFromFolders":[],"EnableContentDownloading":false,"EnableSubtitleDownloading":true,"EnableSubtitleManagement":false,"EnableSyncTranscoding":false,"EnableMediaConversion":false,"EnabledDevices":[],"EnableAllDevices":true,"EnabledChannels":[],"EnableAllChannels":true,"EnabledFolders":["9d7ad6afe9afa2dab1a2f6e00ad28fa6","f137a2dd21bbc1b99aa5c0f6bf02a805","6c2a057148b4d7c20a207c789aba6d07"],"EnableAllFolders":false,"InvalidLoginAttemptCount":0,"EnablePublicSharing":true,"RemoteClientBitrateLimit":0,"AuthenticationProviderId":"Emby.Server.Implementations.Library.DefaultAuthenticationProvider","ExcludedSubFolders":[],"SimultaneousStreamLimit":"2"},"Type":"User","DateLastFetched":1597692223591}

What am I doing wrong here?

Edited by notpiika

Share this post


Link to post
Share on other sites
Luke

Please try that once you have 4.5.0.19. Thanks.

Share this post


Link to post
Share on other sites
notpiika
Posted (edited)
7 minutes ago, Luke said:

Please try that once you have 4.5.0.19. Thanks.

Sure, going to test now. Question: why is simultaneous stream count a string when updating? (at least, in the web client when updating a user, it is)

Edited by notpiika

Share this post


Link to post
Share on other sites
Luke

what do you mean by that?

Share this post


Link to post
Share on other sites
notpiika
1 minute ago, Luke said:

what do you mean by that?

in the web ui -- when apiclient POSTs to /User/id, the policy it gives contains "SimultaneousStreamLimit":"2"

Share this post


Link to post
Share on other sites
Luke

I'm not seeing that. It's an int in the backend.

Share this post


Link to post
Share on other sites
notpiika

I'm seeing it as a string in the frontend.

{"Name":"uwu","ServerId":"xx","Id":"xx","HasPassword":false,"HasConfiguredPassword":false,"HasConfiguredEasyPassword":false,"Configuration":{"PlayDefaultAudioTrack":true,"DisplayMissingEpisodes":false,"GroupedFolders":[],"SubtitleMode":"Default","DisplayCollectionsView":false,"EnableLocalPassword":false,"OrderedViews":[],"LatestItemsExcludes":[],"MyMediaExcludes":[],"HidePlayedInLatest":true,"RememberAudioSelections":true,"RememberSubtitleSelections":true,"EnableNextEpisodeAutoPlay":true},"Policy":{"IsAdministrator":false,"IsHidden":true,"IsHiddenRemotely":true,"IsDisabled":false,"BlockedTags":[],"IsTagBlockingModeInclusive":false,"EnableUserPreferenceAccess":true,"AccessSchedules":[],"BlockUnratedItems":[],"EnableRemoteControlOfOtherUsers":false,"EnableSharedDeviceControl":false,"EnableRemoteAccess":true,"EnableLiveTvManagement":false,"EnableLiveTvAccess":false,"EnableMediaPlayback":true,"EnableAudioPlaybackTranscoding":true,"EnableVideoPlaybackTranscoding":true,"EnablePlaybackRemuxing":true,"EnableContentDeletion":false,"EnableContentDeletionFromFolders":[],"EnableContentDownloading":false,"EnableSubtitleDownloading":true,"EnableSubtitleManagement":false,"EnableSyncTranscoding":false,"EnableMediaConversion":false,"EnabledDevices":[],"EnableAllDevices":true,"EnabledChannels":[],"EnableAllChannels":true,"EnabledFolders":["9d7ad6afe9afa2dab1a2f6e00ad28fa6","f137a2dd21bbc1b99aa5c0f6bf02a805","6c2a057148b4d7c20a207c789aba6d07"],"EnableAllFolders":false,"InvalidLoginAttemptCount":0,"EnablePublicSharing":true,"RemoteClientBitrateLimit":0,"AuthenticationProviderId":"Emby.Server.Implementations.Library.DefaultAuthenticationProvider","ExcludedSubFolders":[],"SimultaneousStreamLimit":"2"},"Type":"User","DateLastFetched":1597692068494}

This is exactly what the web client is sending to the server.

 

So confused why this is happening.

Share this post


Link to post
Share on other sites
Luke

that might be how the web app is sending it but on the back end it is an int, and it comes out of the api on the server as an int.

  • Like 1

Share this post


Link to post
Share on other sites
notpiika
1 hour ago, Luke said:

that might be how the web app is sending it but on the back end it is an int, and it comes out of the api on the server as an int.

gotcha, thanks. sidenote: what are `Type` and `DateLastFetched` used for when updating a user? those are the only parameters that are added to a request when updating a user, other than the user object itself.

Share this post


Link to post
Share on other sites
Luke

Internal use only in the web app. Not part of the api.

Share this post


Link to post
Share on other sites
notpiika

So server doesn't care about it, and I can remove it from my requests, right?

Share this post


Link to post
Share on other sites
Luke

Correct.

  • Like 1

Share this post


Link to post
Share on other sites

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...