Developer

 View Only
  • 1.  AOS-CX REST-API v10.13 run cable-diagnostics

    Posted Aug 11, 2025 01:17 PM

    Hi all,

    I'm having trouble to start a cable-diagnostics test (TDR) through the REST-API on a AOS-CX switch.

    Enviroment:

    Version      : PL.10.13.1010
    Product Name           : JL675A 6100 48G CL4 4SFP+ Swch

    According to the documentation: /system/interfaces/{Interface.name}/interface_diag_tests

    The Interface-Name is present within the url, and the payload itself.

    However I am getting always HTTP-Statuscode 400 and "Invalid data" as response.

    Sample-Code I am using:

    s = requests.Session()

    [...] login [...]

        interface = requests.utils.quote("1/1/1", safe="")

        response = s.post(
            f"https://{addr}/rest/{version}/system/interfaces/{interface}/interface_diag_tests",
            json={"test": "cable_diagnostic", "interface": "1/1/1"},
            verify=False,
        )

    [...] logout [...]

    Any idea, what I am doing wrong?

    I've also tried put/patch - no luck.

    Best,

    Felix



    -------------------------------------------


  • 2.  RE: AOS-CX REST-API v10.13 run cable-diagnostics

    Posted Aug 18, 2025 04:00 AM

    Hi Felix,

    Do you have try to escape "/" ? (using 2%f ?)

    What do you have check the API log ? 



    ------------------------------
    PowerArubaSW : Powershell Module to use Aruba Switch API for Vlan, VlanPorts, LACP, LLDP...

    PowerArubaCP: Powershell Module to use ClearPass API (create NAD, Guest...)

    PowerArubaCL: Powershell Module to use Aruba Central

    PowerArubaCX: Powershell Module to use ArubaCX API (get interface/vlan/ports info)..

    ACEP / ACMX #107 / ACDX #1281
    ------------------------------



  • 3.  RE: AOS-CX REST-API v10.13 run cable-diagnostics

    Posted Aug 18, 2025 08:25 AM

    Hi,

    I've tried to escape 1/1/1 using 

    requests.utils.quote("1/1/1", safe="")

    in the url. I've tried the same within the payload.

    Where can I check the API logs?

    Best,

    Felix

    -------------------------------------------



  • 4.  RE: AOS-CX REST-API v10.13 run cable-diagnostics
    Best Answer

    Posted Aug 18, 2025 01:19 PM

    hi f.hueftle@netze-bw.de" data-itemmentionkey="8041f735-53ab-4226-b786-54467a874d25" biobubblekey="mention7b6b68d5-eece-41ea-aaa0-01845bbd2367" href="https://airheads.hpe.com/profile?UserKey=7b6b68d5-eece-41ea-aaa0-01845bbd2367" data-can-remove="False">@f.hueftle@netze-bw.de! I believe the issue here is in the "body" of the command - the API is expecting the URI path of the interface - this is due to the API being generated by the database so when referring to other "resources" or "entities" in the database like interfaces, the API expects the path/name of the resource - I'll be adding a clause in our developer hub around this behavior - for this API call specifically this is the body and the PATH - to find this URI for any resource (interface/vlan/etc) you can run a GET on that resource and you'll find it following the format of `/rest/<version>/system/<resource>/<id>`:

    PATH
    "https://10.1.1.215/rest/v10.13/system/interfaces/1%2F1%2F1/interface_diag_tests" 
    
    BODY
    {
      "interface": "/rest/v10.13/system/interfaces/1%2F1%2F1",
      "test": "cable_diagnostic"
    }
    
    
    Curl
    
    curl -X POST "https://10.1.1.215/rest/v10.13/system/interfaces/1%2F1%2F1/interface_diag_tests" -H  "accept: */*" -H  "Content-Type: application/json" -H  "x-csrf-token: 3D1QsnrJN_CGYrw2mjpeUA==" -d "{\"interface\":\"/rest/v10.13/system/interfaces/1%2F1%2F1\",\"test\":\"cable_diagnostic\"}"
    
    


    ------------------------------
    Ti Chiapuzio-Wong (they/them)
    HPE Aruba Networking
    ------------------------------



  • 5.  RE: AOS-CX REST-API v10.13 run cable-diagnostics

    Posted Aug 19, 2025 07:26 AM

    Hi @Tiffany.Chiapuzio-Wong,

    thanks for feedback, with the full URI in the payload it works =)

    Please note that also the Swagger UI on the switch itself seems to broken for that part:

    Best,
    Felix
    -------------------------------------------



  • 6.  RE: AOS-CX REST-API v10.13 run cable-diagnostics

    Posted Aug 19, 2025 11:11 AM

    Hi f.hueftle@netze-bw.de" data-itemmentionkey="aa608d65-7e32-4532-80d0-91e2621b5382" biobubblekey="mention7b6b68d5-eece-41ea-aaa0-01845bbd2367" href="https://airheads.hpe.com/profile?UserKey=7b6b68d5-eece-41ea-aaa0-01845bbd2367" data-can-remove="False">@f.hueftle@netze-bw.de ! What firmware version are you on? What behavior are you experiencing? While using the Swagger UI you need to first select the "Login" endpoint and click the "Try it Out" button - then the fields will be editable and you can "send" the request - after logging in repeat that process for this endpoint (Try it out/fill in data/hit execute) - and with this diag test end point, ensure that for the "interface name" you enter the "1/1/1" and for the body's "interface" parameter enter the resource's URI path as I did in my original answer



    ------------------------------
    Ti Chiapuzio-Wong (they/them)
    HPE Aruba Networking
    ------------------------------



  • 7.  RE: AOS-CX REST-API v10.13 run cable-diagnostics

    Posted Aug 19, 2025 12:13 PM

    Hi @Tiffany.Chiapuzio-Wong,

    I am on 10.13. - my point was, that the example in the Swagger UI and the schema definition is broken / does not meet the actual requests requirements with the full ressource URI.

    The default example on the swagger ui shows:

    {
      "interface": "Unknown Type: URI",
      "test": "cable_diagnostic"
    }

    Best, Felix

    -------------------------------------------