Jump to content

Recommended Posts

Posted

Hi all, I am looking for some help with this. 

Yesterday, I was running my test python code for some asset update. It ran fine. 

15 minutes later, I ran the exact same code, and got the following response

 

{
	"@status": false,
	"state": {
		"code": "0007",
		"service": "apps",
		"operation": "updateAsset2",
		"error": "The API key specified is not authorized to invoke this operation (apps\/com.hornbill.servicemanager\/Asset:updateAsset2), please contact your system administrator for assistance"
	}
}

 

After checking that there's no change to the API key, I was advised perhaps Hornbill is doing some background work. I left it until this morning.

This morning, I ran the same code, with no change, and it worked fine the first time. HOWEVER, just 2 minutes after, I ran the same code with a very minor change, and got the same error again. After that, even when I change the code to the original one, I still receive this error.

Could anyone assist me with this please? Thank you

 

Posted

Hi Minh, 

That's odd behaviour for a key which doesn't sound like it's changed. The permissions for the key in the documentation is marked as "none" so long as the key hasn't expired. What was the minor change which you made which caused the error to start to show once more? 

 

Jordan

Posted
7 minutes ago, Jordan Gooding-McGovern said:

Hi Minh, 

That's odd behaviour for a key which doesn't sound like it's changed. The permissions for the key in the documentation is marked as "none" so long as the key hasn't expired. What was the minor change which you made which caused the error to start to show once more? 

 

Jordan

Hi  @Jordan Gooding-McGovern

The key has the validity of another year so I am sure it's not that. Also, nothing was changed from last night (when it stopped working) until this morning (when it works again once) either.

I was playing the different key:value pair of generalProperties that could be sent to the API using updateAsset2. The code below works at first in the morning:

generalProperties":"[{\"name\":\"description\",\"value\":\"did this work?\"},{\"name\":\"notes\",\"value\":\"did this work?\"}]"

 

I then make a minor change to something like which then threw up the error

generalProperties":"[{\"name\":\"State\",\"value\":\"1\"},{\"name\":\"Functional Availability\",\"value\":\"N/A\"}]"

 

Changing the code back to how it was would still give me the error now.

Posted

@Minh Nguyen,

I am pretty sure that generalProperties of "State" and "Functional Availability" do NOT exist. The names will be all camelCaps, starting lowercased and certainly without any spaces.

With "Functional Availability" you likely mean "availabilityState" and "N/A" would be "1" as the value you would want to set it to.

Neither of these mistakes should have caused an error about the API key, though. So I can't help you there.

 

Posted
2 hours ago, SamS said:

@Minh Nguyen,

I am pretty sure that generalProperties of "State" and "Functional Availability" do NOT exist. The names will be all camelCaps, starting lowercased and certainly without any spaces.

With "Functional Availability" you likely mean "availabilityState" and "N/A" would be "1" as the value you would want to set it to.

Neither of these mistakes should have caused an error about the API key, though. So I can't help you there.

 

Yes, I don't think those changes will throw the API authorisation code. I was testing what kind of format/key name is accepted, as I will use the CSV file exported from the Web UI and the headings will need changing before parsing into my full code to update the fields.

 

Could you anyone please help and test this on their end, to see if you they get the same error please?

Posted

Hey @Minh Nguyen I've been having a look through the code for this one and can see that "state" does exist but as Sam suggested "functionalAvailability" does not and it should instead be "operationalState" (or "availabilityState") , the names are all camelCase. I've also run some test api calls and have been unable to replicate the API Key issue on my end. Could you try creating a new one and seeing if you can reproduce the problem with that key? If so, please run me through the steps taken so I can attempt the same. 

Posted

@Jordan Gooding-McGovern

 

Thank you for looking into this. I will try to get a new API, but not being the Hornbill Admin, it's not convenient for me to get one as I will have to ask someone else to create one for me.

I am starting to think there could be a hidden timeout lock, when you are sending a request that is not valid. The reason for this is:

I tried again this morning, with a proper code that I know works, which is below, and got a good response and this was changed when I checked on the web UI.

"generalProperties":"[{\"name\":\"description\",\"value\":\"AAAAAA?\"},{\"name\":\"notes\",\"value\":\"BBBBBB?\"}]"

Right after that, I tried to change the format of the string to below. The reason I changed the format is because I want to see what kind of data I need to manipulate when parsing from the CSV file.

"generalProperties":'[{"name":"description","value":"CCCCC?"},{"name":"notes","value":"DDDDDD?"}]'

This got the the invalid error. 

After that, changing back to the original string that worked just before still gives me the error. I bet if I let it cool down, it may work again first time tomorrow. Hence, I think there's a lockout somewhere.

 

  • 2 weeks later...
Posted

@SamS

Sorry for tagging you SamS, just want to thank you for a couple of things.

First, availabilityState is correct and this would change the field "Functional Availability" on the UI. However, this parameter was not mentioned in the info here

https://docs.hornbill.com/servicemanager-user-guide/asset-management/asset-structure

Secondly, I've started again on this project, and so far today all requested were completed without any API authorisation error. Touch-wood it will keep it that way.

I am also going to use this thread to document a few findings on the way, in case it helps anyone in the future.
- I've found that to update "Owned by" or "Used by" on the webUI, you need to update 3 parameters at the same time for it to take effect:

ownedById / ownedByName / ownedByType

usedById / usedByName / usedByType

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