I'm using Curl through PHP to try to cycle a port, I have done this according to the docs but it's not working.
Getting the error: Array ( [0] => Error for /devices/{serial}/switch/ports/{portId}: None of the fields ('name', 'tags', 'enabled', 'poeEnabled', 'type', 'vlan', 'voiceVlan', 'allowedVlans', 'isolationEnabled', 'rstpEnabled', 'stpGuard', 'linkNegotiation', 'portScheduleId', 'udld', 'accessPolicyType', 'accessPolicyNumber', 'macAllowList', 'stickyMacAllowList', 'stickyMacAllowListLimit', 'stormControlEnabled', 'adaptivePolicyGroupId', 'peerSgtCapable', 'flexibleStackingEnabled', 'daiTrusted' or 'profile') were specified. ) )
According to the docs all I need to post is { "ports": [ "17" ]}
https://developer.cisco.com/meraki/api-latest/#!cycle-device-switch-ports
This is my code:
Solved! Go to solution.
The request should be a POST and not PUT.
> curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
Could it be that your $url statement is set somewhere else aswell, and it's that statement that's being used?
According to your error message, if failing on the endpoint ressource /devices/{serial}/switch/ports/{portId}, but the ressource for cycling the port is /devices/{serial}/switch/ports/cycle as you've also stated yourself.
So I'm assuming that $url is being set somewhere to /devices/{serial}/switch/ports/{portId}
I haven't worked with PHP for a long time, but I think it looks correct.
The URL is only set as https://api.meraki.com/api/v1/devices/{serial}/switch/ports/cycle
The response is strange.
you are not changing the {serial} to any real serial number in the URL.
the URL should look like this https://api.meraki.com/api/v1/devices/Q2BX-XXXX-XXXX/switch/ports/cycle
just with the real serial number of your switch
No it's there, I didn't want to display it in this forum.
it's in the format Q2GX-XXXX-XXXX
The request should be a POST and not PUT.
> curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
Yes that was it I missed that. Thank you!