Error "'NoneType' object has no attribute 'get'" when executing runbook via API | Nutanix Community
Skip to main content
Solved

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

  • November 24, 2021
  • 7 replies
  • 1533 views

Forum|alt.badge.img+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.

Best answer by JoseNutanix

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. 
View original
Did this topic help you find an answer to your question?
This topic has been closed for comments

7 replies

JoseNutanix
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • 150 replies
  • November 24, 2021

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. 


Forum|alt.badge.img+2
  • Author
  • Trendsetter
  • 42 replies
  • November 24, 2021

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.


Forum|alt.badge.img+2
  • Author
  • Trendsetter
  • 42 replies
  • November 24, 2021

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?


JoseNutanix
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • 150 replies
  • November 26, 2021

Hey Martin,

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

 


Forum|alt.badge.img+2
  • Author
  • Trendsetter
  • 42 replies
  • December 3, 2021

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"
            }
        ]
    }
}'

 


JoseNutanix
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • 150 replies
  • Answer
  • December 3, 2021

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. 

Forum|alt.badge.img+2
  • Author
  • Trendsetter
  • 42 replies
  • December 3, 2021

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!