Solved

Error "'NoneType' object has no attribute 'get'" when executing runbook via API

  • 24 November 2021
  • 7 replies
  • 1200 views

Userlevel 2
Badge +2

Hi.

I’ve verified with this post and this post that I’m sending the parameters correctly and that the variables in my runbook are set to Runtime. 

I’m also doing a POST call but I still get an internal server error with the message "'NoneType' object has no attribute 'get'".

Here’s the body of my call:

{
    "spec": {
          "args": [
            {
              "name": "email",
              "value": "mema@tlke.se"
            },
            {
              "name": "displayName",
              "value": "Mom MEmem"
            },
            {
              "name": "userName",
              "value": "momemom"
            },
            {
              "name": "accountName",
              "value": "MAM, MSM 1"
            },
            {
                "name": "ticketID",
                "value": "794"
            }
          ]
        }
      }
    }
  }

The runbook has multiple tasks, does that change how I send arguments to it?

Thanks.

icon

Best answer by JoseNutanix 3 December 2021, 14:00

View original

This topic has been closed for comments

7 replies

Userlevel 4
Badge +5

Hi Martin,

Not sure if that would be the problem, but your JSON payload is not compliance. You have to remove two curly brackets from the end of the payload. 

About the number of tasks, it doesn’t matter. If you are still having problems, make a simple runbook with a single task and a single variable to practice and check if it works for you. Once you confirm, then move to the one failing. 

Userlevel 2
Badge +2

Hi Jose.

Doh! I checked the syntax of the JSON with Prettier and didn’t get any errors so I just assumed that it was kosher. That’s what I get for assuming things. 

Unfortunately that didn’t help, I still get the same error. I’ll give it a try with a super simple runbook and see.

Thanks for the quick reply.

Userlevel 2
Badge +2

Hello Jose.

It doesn’t matter that I use a super simple runbook. I even replicated the one you outlined in this post, I still get the same error. :/

Is there a log in Calm I can check to get more information?

Userlevel 4
Badge +5

Hey Martin,

Could you paste your request in curl format here? Feel free to anonymize any sensitive information.

 

Userlevel 2
Badge +2

Hi Jose.

Sorry for the delayed response. Here’s the curl request, minus some potentially sensitive stuff:

curl --location --request POST 'https://[prism-central-server]:9440/api/nutanix/v3/runbooks/93fe2c76-4562-45bc-e34e-20a727e33e12/run' \
--header 'Content-Type: application/*' \
--header 'Authorization: Basic (removed)' \
--header 'Cookie: NTNX_IGW_SESSION=(removed)' \
--data-raw '{
"spec": {
"args": [
{
"name": "VAR_TEST",
"value": "THIS IS A TEST"
}
]
}
}'

 

Userlevel 4
Badge +5

Hi Martin,

No worries, two things here. With just the first one is enough to make it work, but you can even simplify more:

  1. You have to set the Context-Type to application/json . With this is enough
  2. As a bonus to simplify, you can get rid of the header for Cookie. With Authorization is enough. 
Userlevel 2
Badge +2

Ah, thanks! 

Not sure where I got the application/* header from (I probably copied a request and didn’t notice), and the cookie is from Postman - I don’t have that in my actual request.

Many thanks for the help!