Jump to content

Value cannot be null. (Parameter 'appName')


ginjaninja

Recommended Posts

ginjaninja

am trying to get back into learning emby api

but i cant even successfully test "/Users/AuthenticateByName" in the swagger interface,

 

if i provide correct "Username/Pw" credentials i get "Value cannot be null. (Parameter 'appName')"

if i provide incorrect credentials, i get "Invalid username or password entered."

 

tested on 4.5.0.6

 

i am probably being dull but just in case, is the swagger interface working or this command?

 

thank you

@@chef

Link to comment
Share on other sites

chef

Do we still have to pass the password encrypted two different ways? Md5 and Sha ?

Link to comment
Share on other sites

PenkethBoy

i thought that was removed ages ago

 

pw is now sent in plain text

 

Show us your full text that you have supplied to swagger

Link to comment
Share on other sites

ginjaninja

thanks

 

i have header as

Client='1', Device='2', DeviceId='3', Version='4'

and the json as

 

{
  "Username": "User One",
"Pw": "MyPassword"
}

the help says as of 1st April 2018 only 'Pw' is required (only Pw was required last time i was learning)

Link to comment
Share on other sites

PenkethBoy

Yep Swagger does not work - doesn't matter what you put in it fails with the same error - i have a suspicion that its because its not adding "?format=json" on after /AuthenticateByName

 

AuthenticateByName does work though outside of swagger - use it almost everyday - or lots of people would be complaining

 

What language are you using/going to use with the api?

Link to comment
Share on other sites

ginjaninja

Yep Swagger does not work - doesn't matter what you put in it fails with the same error - i have a suspicion that its because its not adding "?format=json" on after /AuthenticateByName

 

AuthenticateByName does work though outside of swagger - use it almost everyday - or lots of people would be complaining

 

What language are you using/going to use with the api?

thanks for confirming ..probably will use powershell..

 

did i see on a previous poat you use powershell also?...could you share a template poweshell script to post http and handle a response to/from the api to help get me started? thank you

 

Sent from my SM-G955F using Tapatalk

Link to comment
Share on other sites

PenkethBoy

Hi

 

Yes i use Powershell

 

1. I suggest if you are going to do anything significant that you install Powershell 7 (core) - so you benefit from the latest updates (sits alongside PS 5.1 so you can use both as necessary)

2. Also install Visual Studio Code (free) and install the Powershell Module - will make your life a lot easier when learning - avoid using the PS ISE - its very basic and is not part of PS7

3. Swagger is approx 95% correct and works

4. However the best tool in most cases is to do what you want to do in the web app - then look at the Emby log - and you will see how emby does it - also several endpoints are not in swagger but appear in the log

 

5. To authenticate to Emby via Powershell - save this to a ps1 file - can be named anything you like.

 

# Amend for you server and user
$embyServerUrl = "http://192.168.1.56:8096"
$Emby_User_Name = "" # best if this is an admin user - can be a normal user but will be limited on what it can do
$Emby_User_Pwd = '' # Note: if you have a $ in your password "" should not be used as PS will try to evaluate the $ and the login will fail - so use ''


# these can be anything you want - some of this info appears on dashboard and devices pages
$embyClientName = "PS-Testing"
$embyDeviceName = "PowerShell"
$embyDeviceId = "123456"
$embyApplicationVersion = " - 0.0.1 Alpha"


function Get-EmbyAccessToken ($Username, $Pwd)
{
$authUrl = "{0}/Users/AuthenticateByName?format=json" -f $embyServerUrl
$postParams = @{Username=$username;pw=$Pwd} | ConvertTo-Json
$Headers = @{"Authorization"="Emby Client=`"$embyClientName`", Device=`"$embyDeviceName`", DeviceId=`"$embyDeviceId`", Version=`"$embyApplicationVersion`""}

return (Invoke-WebRequest -Uri $authUrl -Method POST -Body $postParams -ContentType "application/json" -Headers $Headers)
}


$authResult = Get-EmbyAccessToken -Username $Emby_User_Name -Pwd $Emby_User_Pwd
$user = $authResult.Content | ConvertFrom-Json
$user | ConvertTo-Json -Verbose -Depth 100 | Out-File "$PSScriptRoot\User-New.json"

Write-Host "User Access Token: "$user.AccessToken

Exit

 

 

To run the ps1 file open a PS console window - navigate to the location of the script and

 

".\User-Test.ps1" - without the quotes

 

will return the User.AccessToken to the screen and save a User-New.json file with all the data returned from Emby in the same location as the script ($PSScriptRoot)

 

To use the access token you need to add the following to the above before  "Exit" - just a random example

 

 

$MediaUrl = $embyServerUrl + "/emby/users/" + $User.User.Id + "/items?Fields=Tags,Genres,Childcount%2CProviderIds%2CRemoteTrailers%2CDateCreated,LocalTrailerCount&Recursive=true&SortBy=SortName&SortOrder=Ascending&IncludeItemTypes=Series" + "&api_key=" + $User.AccessToken

$TestResult = Invoke-WebRequest -Uri $MediaUrl -Method Get

$Media = $TestResult.Content | ConvertFrom-Json

$Media | ConvertTo-Json -Verbose -Depth 100 | Out-File "$PSScriptRoot\TVSeries.json"

 

 

Which will give all you TV Series from Emby and save them to a json file

 

Obviously the json files are just for reference and you only need to save them for testing

 

 

Will leave amending an existing item for another day as its more complicated and easy to get wrong and trash the item entry in emby. Suggest you setup a second test server that you can rebuild quickly if things go south.

 

Have fun

 

  • Like 1
Link to comment
Share on other sites

PenkethBoy

@@ginjaninja

 

If you have questions while you are getting the hang off things post here and i will try and answer them for you

 

Also can you give me an outline of what you are trying to achieve

Link to comment
Share on other sites

ginjaninja

thank you,

i would like to get the path of all my series, so i can download a file  to the root of every series from BASEURL+/TVDBID/TVDBID.xyz

Link to comment
Share on other sites

PenkethBoy

Each Api endpoint returns by default different amounts of "data" - so what you get is what emby uses in the web app etc

 

But most endpoints also allow you to specify extra data - which in this case you want the path to a the series folder

 

So...

../emby/Items?Recursive=true&Fields=Path&IncludeItemTypes=Series&api_key=<api_key>

will give you all you series with the path - all i did was add "path" to the fields property and limited the types returned to series with includeitemtypes 

 

both are available in swagger so experiment with adding other optional fields (as i showed you in my previous example above) and the other swagger options to limit or target specific things

Link to comment
Share on other sites

ginjaninja

Each Api endpoint returns by default different amounts of "data" - so what you get is what emby uses in the web app etc

 

But most endpoints also allow you to specify extra data - which in this case you want the path to a the series folder

 

So...

../emby/Items?Recursive=true&Fields=Path&IncludeItemTypes=Series&api_key=<api_key>

will give you all you series with the path - all i did was add "path" to the fields property and limited the types returned to series with includeitemtypes 

 

both are available in swagger so experiment with adding other optional fields (as i showed you in my previous example above) and the other swagger options to limit or target specific things

thanks again that makes alot of sense

Link to comment
Share on other sites

ginjaninja

Thanks @@PenkethBoy, , much more fun when you have a bit of help.

i now have a working theme music downloader

 

Had to work out how to iterate through the converted json, extracting variables as you go, so this might help others

$MediaUrl = $embyServerUrl + "/emby/users/" + $User.User.Id + "/Items?Fields=Path,ProviderIds&Recursive=true&SortBy=SortName&SortOrder=Ascending&IncludeItemTypes=Series" + "&api_key=" + $User.AccessToken
$TestResult = Invoke-WebRequest -Uri $MediaUrl -Method Get

$Shows = $TestResult.Content | ConvertFrom-Json

Foreach ($show in $Shows.items) {
    
    $ThemeUrl = $themebaseUrl + $show.ProviderIds.Tvdb + ".mp3"
    $Filepath = $show.path + "\Theme.mp3"
    Invoke-WebRequest -Uri $ThemeUrl -OutFile $Filepath
}
Link to comment
Share on other sites

  • 3 weeks later...
Behinder

I am giving up having the same problem.

I am using Paw to testing API this is really annoying that just first endpoint encountered does not work, hell there is not even 'appNAme' parameter described in the docs, who wrote that API????

it does not even detect parameter set. I wasted 2 days to make it work and since I dont have a master degree from Hogwart looks I stay with Plex little longer.

 

5ec314f1cb2e0_ZrzutEkranu20200519o010602
 

Not to mention obvious error here 
5ec315b431a4b_ZrzutEkranu20200519o010904

 

How the Token can be in 'authenticateByName' header if the token is returned by the response from that endpoint ???? seriously ????

Link to comment
Share on other sites

 

 

How the Token can be in 'authenticateByName' header if the token is returned by the response from that endpoint ???? seriously ????

When authenticating the token will be omitted. That required header entry is being displayed for all endpoints generically. Obviously as you've realized, it needs to be slightly adjusted when not yet authenticated.

Link to comment
Share on other sites

  • 4 months later...
jscoys
On 5/18/2020 at 7:12 PM, Behinder said:

I am giving up having the same problem.

I am using Paw to testing API this is really annoying that just first endpoint encountered does not work, hell there is not even 'appNAme' parameter described in the docs, who wrote that API????

it does not even detect parameter set. I wasted 2 days to make it work and since I dont have a master degree from Hogwart looks I stay with Plex little longer.

 

5ec314f1cb2e0_ZrzutEkranu20200519o010602
 

Not to mention obvious error here 
5ec315b431a4b_ZrzutEkranu20200519o010904

 

How the Token can be in 'authenticateByName' header if the token is returned by the response from that endpoint ???? seriously ????

Hum I'm having the same "Value cannot be null. (Parameter 'appName')" than the others, @Luke I'm using POSTMAN, can you explain me exactly what I have to do to make it work?

Here is what I'm declaring in the headers:

image.png.fa9f2499bb8bbdcd08d133b7bf7bebac.png

 

And here in the body:

image.png.fea307897312f3d1fd94ccdecee09926.png

 

What I'm doing wrong? Thx.

Link to comment
Share on other sites

jscoys

OK!! I figured it out. Instead of separating the different parameters in the headers, you have to put only one called "Authorization" and put all the other parameters (Client, Device, DeviceId...) in its value as a whole. An example here (In bulk Edit view of PostMan):

Authorization:Emby UserId="blah", Client="MyClient", Device="Samsung Galaxy SIII", DeviceId="123456", Version="1.0.0.0""

You can copy the string above in your bulk edit view in Postman and then switch to Key-Value Edit...

Edited by jscoys
  • Agree 1
Link to comment
Share on other sites

  • 10 months later...
  • 5 months later...

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