API doesn't work.HELP

Forum for questions and support relating to the 1.34.x releases only.
testsia
Posts: 6
Joined: Mon Aug 03, 2020 9:22 am

API doesn't work.HELP

Post by testsia »

Hello smart people.
Help me figure it out.
I have zoneminder configured on Ubuntu.
I access it from the internet and see my cameras.
But I want to see cameras through the app zmNinja on my phone.
I check the work API local:
http://ip-local/zm/index.php
works great

Port forwarding is configured on my router.
I check the work API internet:
http://ip-internet/zm/index.php
works great

but when i try to run the app and see the cameras i get an error.
zmninja api error

What am I doing wrong?
LOG:
zmNinja version:1.4.009 (desktop)
ZoneMinder version:

Aug 3, 2020 01:50:05 PM DEBUG Does login need to hear the wizard? false
Aug 3, 2020 01:50:06 PM DEBUG User tapped save, calling SaveItems
Aug 3, 2020 01:50:06 PM DEBUG Clearing Multiport...
Aug 3, 2020 01:50:06 PM DEBUG Clearing all unsupported flags
Aug 3, 2020 01:50:06 PM DEBUG obfuscate: original:13338 obfuscated:2776 scheme:lzs
Aug 3, 2020 01:50:06 PM DEBUG CACHE: Flushing all network API caches...
Aug 3, 2020 01:50:06 PM DEBUG Inside save Items
Aug 3, 2020 01:50:06 PM DEBUG Setting isFirstUse to:false
Aug 3, 2020 01:50:06 PM DEBUG obfuscate: original:13338 obfuscated:2776 scheme:lzs
Aug 3, 2020 01:50:06 PM DEBUG Setting server version to:
Aug 3, 2020 01:50:06 PM DEBUG Setting multi-port to:false
Aug 3, 2020 01:50:06 PM DEBUG obfuscate: original:13338 obfuscated:2776 scheme:lzs
Aug 3, 2020 01:50:06 PM DEBUG _doLogoutAndLogin: Clearing cookies
Aug 3, 2020 01:50:06 PM INFO No reachable config: "No servers reachable"
Aug 3, 2020 01:50:06 PM INFO In Auth State trans: Not logged in, requested to go to {"data":{"requireLogin":false},"cache":false,"url":"/invalidapi","templateUrl":"templates/invalidapi.html","controller":"zmApp.InvalidApiCtrl","name":"app.invalidapi"}
Aug 3, 2020 01:50:06 PM INFO Validating APIs at /host/getVersion.json?
Aug 3, 2020 01:50:06 PM INFO Login data not changed, not saving
Aug 3, 2020 01:50:06 PM INFO API login error {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":"/host/getVersion.json?","headers":{"Accept":"application/json, text/plain, */*","X-ZmNinja":"zmNinja_%APPVER%"},"withCredentials":true},"statusText":""}
Aug 3, 2020 01:50:06 PM DEBUG Saved isFirstUse ok
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API doesn't work.HELP

Post by asker »

testsia wrote: Mon Aug 03, 2020 10:52 am
I check the work API local:
http://ip-local/zm/index.php
works great

Port forwarding is configured on my router.
I check the work API internet:
http://ip-internet/zm/index.php
works great

but when i try to run the app and see the cameras i get an error.
zmninja api error

What am I doing wrong?
Neither of the URLs you listed above are for the API. They are for the web console (two different things).
Please follow this guide closely.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
testsia
Posts: 6
Joined: Mon Aug 03, 2020 9:22 am

Re: API doesn't work.HELP

Post by testsia »

I am grateful to you for your answer.
I read the entire manual, I went through each of the points step by step.
My English is not very good.....
But I tried.
I must indicate the address in the program: ???
http://ip-internet/zm/api/monitors.json

The app does not display.
I can give you access. Can you see what's wrong?
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API doesn't work.HELP

Post by asker »

Let's forget about the app for now.
Please follow the link I gave above and please post results step by step in the guide. Just use a browser (not zmNinja).
Replace text "server" with your ZM hostname or IP address.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
testsia
Posts: 6
Joined: Mon Aug 03, 2020 9:22 am

Re: API doesn't work.HELP

Post by testsia »

http://<ip removed>/zm/api/host/getVersion.json

Code: Select all

version	"1.34.16"
apiversion	"2.0"
http://<ip removed>/zm/api/monitors.json

Code: Select all

0	
Monitor	
Id	"1"
Name	"Ogorod"
Notes	""
ServerId	"0"
StorageId	"0"
Type	"Ffmpeg"
Function	"Modect"
Enabled	"1"
LinkedMonitors	null
Triggers	""
Device	""
Channel	"0"
Format	"0"
V4LMultiBuffer	null
V4LCapturesPerFrame	"1"
Protocol	null
Method	"rtpRtsp"
Host	"http://192.168.1.10:8899/onvif/device_service"
Port	""
SubPath	""
Path	"rtsp://<credentials removed>@192.168.1.10:554/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_stream"
Options	null
User	null
Pass	null
Width	"1920"
Height	"1080"
Colours	"4"
Palette	"0"
Orientation	"ROTATE_0"
Deinterlacing	"0"
DecoderHWAccelName	null
DecoderHWAccelDevice	null
SaveJPEGs	"3"
VideoWriter	"0"
OutputCodec	null
OutputContainer	null
.......................................
http://<ip removed>/zm/api/events.json

Code: Select all

events	
0	
Event	
Id	"1"
MonitorId	"2"
StorageId	"0"
SecondaryStorageId	"0"
Name	"Event- 1"
Cause	"Motion"
StartTime	"2020-07-31 13:52:44"
EndTime	"2020-07-31 13:52:53"
Width	"1920"
Height	"1080"
Length	"9.15"
Frames	"61"
AlarmFrames	"1"
DefaultVideo	""
SaveJPEGs	"3"
TotScore	"27"
AvgScore	"27"
MaxScore	"27"
Archived	"0"
Videoed	"0"
Uploaded	"0"
Emailed	"0"
Messaged	"0"
Executed	"0"
Notes	"Motion: All"
StateId	"1"
Orientation	"ROTATE_0"
DiskSpace	"22177248"
Scheme	"Medium"
Locked	false
MaxScoreFrameId	"6"
FileSystemPath	"/var/cache/zoneminder/events/2/2020-07-31/1"
1	
Config Server

Code: Select all

LANG_DEFAULT
ru_ru

OPT_USE_AUTH

AUTH_TYPE builtin  remote

AUTH_RELAY hashed  plain  none

AUTH_HASH_SECRET
!QAZ2wsx

AUTH_HASH_IPS

AUTH_HASH_TTL
2

AUTH_HASH_LOGINS

ENABLE_CSRF_MAGIC

OPT_USE_API

OPT_USE_LEGACY_API_AUTH

OPT_USE_EVENTNOTIFICATION

OPT_USE_GOOG_RECAPTCHA

OPT_GOOG_RECAPTCHA_SITEKEY

OPT_GOOG_RECAPTCHA_SECRETKEY


SYSTEM_SHUTDOWN

TIMEZONE
(GMT+02:00) Europe, Rome

OPT_FAST_DELETE

FILTER_RELOAD_DELAY
300

FILTER_EXECUTE_INTERVAL
60

MAX_RESTART_DELAY
600

STATS_UPDATE_INTERVAL
60

WATCH_CHECK_INTERVAL
10

WATCH_MAX_DELAY
45

RUN_AUDIT

AUDIT_CHECK_INTERVAL
900

AUDIT_MIN_AGE
86400

OPT_CONTROL

OPT_TRIGGERS

CHECK_FOR_UPDATES

CSP_REPORT_URI

TELEMETRY_DATA

TELEMETRY_INTERVAL
14*24*60*60

UPDATE_CHECK_PROXY

SHM_KEY
0x7a6d0000

COOKIE_LIFETIME
3600
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API doesn't work.HELP

Post by asker »

This looks good. Can you make sure these APIs work from your mobile phone too? (Same test, using a mobile browser). If it works, please post a picture of your zmNinja settings page.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
testsia
Posts: 6
Joined: Mon Aug 03, 2020 9:22 am

Re: API doesn't work.HELP

Post by testsia »

Screenshots below.
I also tried to install zmninja-pro on my computer and I get the same error

(links removed by admin to take out private data)


Code: Select all

*** Before you send the logs, please make sure you remove any sensitive information. zmNinja tries to filter out passwords, but it is possible that passwords will be included if you include them in URLs, for example ***


zmNinja version:1.4.009 (desktop)
ZoneMinder version:

Aug 3, 2020 05:58:11 PM DEBUG Clearing all unsupported flags
Aug 3, 2020 05:58:11 PM DEBUG obfuscate: original:32491 obfuscated:5582 scheme:lzs
Aug 3, 2020 05:58:11 PM DEBUG CACHE: Flushing all network API caches...
Aug 3, 2020 05:58:15 PM DEBUG Does login need to hear the wizard? false
Aug 3, 2020 05:58:17 PM DEBUG User tapped save, calling SaveItems
Aug 3, 2020 05:58:17 PM DEBUG Clearing Multiport...
Aug 3, 2020 05:58:17 PM DEBUG Clearing all unsupported flags
Aug 3, 2020 05:58:17 PM DEBUG obfuscate: original:32491 obfuscated:5582 scheme:lzs
Aug 3, 2020 05:58:17 PM DEBUG CACHE: Flushing all network API caches...
Aug 3, 2020 05:58:18 PM DEBUG Inside save Items
Aug 3, 2020 05:58:18 PM DEBUG Setting isFirstUse to:false
Aug 3, 2020 05:58:18 PM DEBUG obfuscate: original:32491 obfuscated:5582 scheme:lzs
Aug 3, 2020 05:58:18 PM DEBUG Setting server version to:
Aug 3, 2020 05:58:18 PM DEBUG Setting multi-port to:false
Aug 3, 2020 05:58:18 PM DEBUG obfuscate: original:32491 obfuscated:5582 scheme:lzs
Aug 3, 2020 05:58:18 PM DEBUG _doLogoutAndLogin: Clearing cookies
Aug 3, 2020 05:58:18 PM INFO No reachable config: "No servers reachable"
Aug 3, 2020 05:58:18 PM INFO In Auth State trans: Not logged in, requested to go to {"data":{"requireLogin":false},"cache":false,"url":"/invalidapi","templateUrl":"templates/invalidapi.html","controller":"zmApp.InvalidApiCtrl","name":"app.invalidapi"}
Aug 3, 2020 05:58:18 PM INFO Validating APIs at /host/getVersion.json?
Aug 3, 2020 05:58:18 PM INFO Login data not changed, not saving
Aug 3, 2020 05:58:18 PM INFO API login error {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":"/host/getVersion.json?","headers":{"Accept":"application/json, text/plain, */*","X-ZmNinja":"zmNinja_%APPVER%"},"withCredentials":true},"statusText":""}
Aug 3, 2020 05:58:18 PM DEBUG Saved isFirstUse ok
which reference is correct?
http://ip-internet/zm/api/monitors.json
or
http://ip-internet/zm/api
????
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API doesn't work.HELP

Post by asker »

1. Please post a screenshot of your zmNinja app settings screen (Menu->Settings)
2. It looks like you don't have any authentication in ZM enabled. I was able to directly use your IP and see results (I've removed the IP from the API posts). If you don't have authentication enabled, please make sure you turn off authentication in zmNinja
3. Go to zmNinja->Menu->clear API cache, exit app and start again
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
testsia
Posts: 6
Joined: Mon Aug 03, 2020 9:22 am

Re: API doesn't work.HELP

Post by testsia »

<admin deleted>
my head is already spinning ... did as you said
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API doesn't work.HELP

Post by asker »

Ok, let me take a look.
Can you send me access details of ZM console ? pliablepixels @ gmail

(Also, please make sure your logs/pictures don't have personal info like public IPs - if you don't have auth, anyone can access them)
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API doesn't work.HELP

Post by asker »

Please don't send me messages via the forum. Can you please contact me via email at pliablepixels gmail com
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: API doesn't work.HELP

Post by david1234 »

can I connect to you also ?

I did everything it said in the manual ,
but the API is not working
I get error

Code: Select all

curl -XPOST -d "user=David&pass=DavidPass" http://10.0.0.105/zm/api/login.json
{"name":"Not Found","message":"Not Found","url":"\/api\/zm\/api\/host\/login.json"
Thanks,
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API doesn't work.HELP

Post by asker »

I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: API doesn't work.HELP

Post by david1234 »

same resualt

Code: Select all

curl -XPOST -d "user=David&pass=Davidpass" http://10.0.0.105/zm/api/host/login.json
{"name":"Not Found","message":"Not Found","url":"\/api\/zm\/api\/host\/login.json"}pi@raspberrypi:~$
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API doesn't work.HELP

Post by asker »

There is something wrong with how you have configured your API.
"url":"\/api\/zm\/api\/host\/login.json"

Unfortunately, that is not something I can help 1-1 with. You may want to start a new thread about it and mention your OS, how you installed etc. Looks like a API routing problem. This is a different issue from the OP who had API working correctly, but zmNinja erroring. In your case, the API itself seems misconfigured.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Post Reply