VMware Networking Community
Czernobog
Expert
Expert

NSX ALB Avi 30.1.1 - macro API "Input object does not have model_name field" even though present

I've started evaluating the Avi/NSX ALB product a short while ago and try to automate the creation of some of the objects.

When using the macro API to create a virtual service I cannot get past the "Input object does not have model_name field" error.

How this works is pretty confusing.

First I have created a new virtual service using the UI and captured the query using the browsers' developer mode. Afterwards I used curl to make a request, for which I copied the payload 1:1 from what was captured earlier. The error "Input object does not have model_name field" accompanzing a http error 400 was returned.

I've checked the payload, the model_name field was actually missing. Instead the "uri_path":"/api/virtualservice" was present. Manually adding the "model_name": "VirtualService" field to the payload did not resolve the error.

Using the example provided in MACRO API (avinetworks.com) also results in the error mentioned above.

Am I doing something wrong here? How does the query work, when executed using the UI without the model_name field?

Overall, the REST API makes a pretty janky first impression. I've noticed a similar problem when creating a new server pool. Copied the payload from browser dev mode, query returns an errro 400 with reason of being not able to interpret the healt monitor field...

0 Kudos
3 Replies
EvertAM
Enthusiast
Enthusiast

Do you have a (cleaned up if needed) example of the payload you used?

0 Kudos
Czernobog
Expert
Expert

This can be tested with the example provided in the documentation, it end with the response:

Response: {

"error": "Input object does not have model_name field"

}

ERROR!: 400 Client Error: BAD REQUEST for url: https://{base_url}/api/macro

 

I get the same response with my custom VS:

 

    payload = {
        "model_name": "VirtualService",
        "data": {
            "name": "n_vs",
            "services": [
                {
                    "port": 80
                }
            ],
            "vip":[
                {
                    "ip_address": {
                        "type": "V4",
                        "addr": "2.2.2.2"
                    }
                }
            ],
            "application_profile_ref": "/api/applicationprofile?name=n_app_http",
            "pool_ref_data": {
                "name": "n_pool",
                "servers": [
                    {
                        "ip": {
                            "type": "V4",
                            "addr": "1.1.1.1"
                        }
                    }
                ],
                "health_monitor_refs_data": [
                    {
                        "type": "HEALTH_MONITOR_HTTP",
                        "name": "n_http",
                        "http_monitor": {
                            "http_response_code": [
                                {
                                    "code": "HTTP_2XX"
                                }
                            ]
                        }
                    }
                ]
            } 
        }
    }

 

0 Kudos
p0wertje
Hot Shot
Hot Shot

Try this, I have tested this on 22.1 and not on 30.1
Please be aware that 30.1 is not the advised version to run. 22.1 is the advised version.

{
    "model_name": "VirtualService",
    "data": {
        "name": "n_vs",
        "services": [
            {
                "port": 80
            }
        ],
        "vsvip_ref_data": {
            "name": "n_vsvip",
            "vip":[
                {
                    "vip_id": "1",
                    "ip_address": {
                        "type": "V4",
                        "addr": "2.2.2.2"
                    }
                }
            ]
        },
        "application_profile_ref": "/api/applicationprofile?name=System-HTTP",
        "pool_ref_data": {
            "name": "n_pool",
            "servers": [
                {
                    "ip": {
                        "type": "V4",
                        "addr": "1.1.1.1"
                    }
                }
            ],
            "health_monitor_refs_data": [
                {
                    "type": "HEALTH_MONITOR_HTTP",
                    "name": "n_http",
                    "http_monitor": {
                        "http_response_code": [  
                            "HTTP_2XX"
                        ]
                    }
                }
            ]
        } 
    }
}

 

Cheers,
p0wertje | VCIX6-NV | JNCIS-ENT | vExpert
Please kudo helpful posts and mark the thread as solved if solved