BlazejosP / huawei-sun2000-API-CLI

Huawei SUN2000 compatible devices which working with Huawei Cloud Service command line bash API for monitoring or download data from their FusionSolarApp API
https://www.buymeacoffee.com/blazejosP
GNU General Public License v3.0
110 stars 15 forks source link

jq: error (at <stdin>:1): Cannot iterate over null (null) #32

Closed nb2001c closed 1 year ago

nb2001c commented 1 year ago

Hello, On Dec 9 2022 it was working perfectly. Starting on 10 Dec 2022 it didn't work. The output error is regarding jq:

Please wait connecting! Connection to API

API login to server OK Username & Password accepted by Huawei Server Normal Status jq: error (at :1): Cannot iterate over null (null)

ndefined Error \nReturned data:

What is wrong? Thank you!

januweness commented 1 year ago

Hi, the problem is always the same to get the token. In this case, a small change should fix it, in line 1002 to replace: local logowanie=${array[21]} by local logowanie=${array[23]}

Cheers, Jan-Uwe

From: nb2001c @.> Sent: 13 December 2022 10:32 To: BlazejosP/huawei-sun2000-API-CLI @.> Cc: Subscribed @.***> Subject: [BlazejosP/huawei-sun2000-API-CLI] jq: error (at :1): Cannot iterate over null (null) (Issue #32)

Hello, On Dec 9 2022 it was working perfectly. Starting on 10 Dec 2022 it didn't work. The output error is regarding jq:

Please wait connecting! Connection to API

API login to server OK Username & Password accepted by Huawei Server Normal Status jq: error (at :1): Cannot iterate over null (null)

ndefined Error \nReturned data:

What is wrong? Thank you!

- Reply to this email directly, view it on GitHubhttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FBlazejosP%2Fhuawei-sun2000-API-CLI%2Fissues%2F32&data=05%7C01%7CJan.Uwe.Ness%40esa.int%7Cc860ba8cb7364c04448208dadcf801fd%7C9a5cacd02bef4dd7ac5c7ebe1f54f495%7C0%7C0%7C638065254978700341%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ElJkbpPY%2FE4dFM9TU3Z%2B3r%2Bg2jpmrHRGSpPw2fXx3IM%3D&reserved=0, or unsubscribehttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABTM3AEUMIFCQRTJB5C572LWNA7ADANCNFSM6AAAAAAS47AOQ4&data=05%7C01%7CJan.Uwe.Ness%40esa.int%7Cc860ba8cb7364c04448208dadcf801fd%7C9a5cacd02bef4dd7ac5c7ebe1f54f495%7C0%7C0%7C638065254978700341%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=bLXOfuqZJPpqrJkZYXw1w8w2rzRu21acW%2FbEPiaUVwY%3D&reserved=0. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>

This message is intended only for the recipient(s) named above. It may contain proprietary information and/or protected content. Any unauthorised disclosure, use, retention or dissemination is prohibited. If you have received this e-mail in error, please notify the sender immediately. ESA applies appropriate organisational measures to protect personal data, in case of data privacy queries, please contact the ESA Data Protection Officer @.***).

nb2001c commented 1 year ago

Modified line 1002 in function.sh. Unfortunately the same error. I assume that the problem is somewhere elsewhere. Looking forward for your help. Thank you!

nb2001c commented 1 year ago

Hello,

I uncomment line 1043: echo "XSRF-TOKEN: "$xsrf_token

The result is: XSRF-TOKEN: XSRF-TOKEN=x-g45g44hgtidfcbdjvv9d5ivtiqk51frvpdql7u89mqg4qkk5k9qknw9j4b1hjusb8ailmkmo5ebt075i89kb5gnw059gjvfvirfx2rs5heqodeeqg5im2neonvupbv05

So, the problem is the variable xrsf_token still contain teh string "XSRF-TOKEN="

I added into function.sh a new line just before line 1040 which is: xsrf_token=$(echo $xsrf_token). The new line will subtract only the token:

xsrf_token=$(awk '{print substr($0, 13, 200)}' <<< $xsrf_token)

After this small change, the script is working again!

I'm not a good programmer in bash so please don't blame me so much. I hope you can adjust the code in a professional way. Looking for a new software version.

Thank you so much!

BlazejosP commented 1 year ago

I also repaired login into service so now XLRF-token is accepted again and look that you can use service. Like usually Huawei changes small things related to token answer from API without warning and now that was on different potion in our array. Check update in functions.sh

BlazejosP commented 1 year ago

Hope that solved problem