cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1332
Views
5
Helpful
0
Replies

PUT method via PHP CURL

dbonagir
Cisco Employee
Cisco Employee

Greetings

I'm trying to update a resource via the put method using PHP curl as below.

I keep getting 405 method not available. Has anyone tried this before? If so can you please share how to update the resource this way?

Intention of this is to provide a php frontend for supervisor to perform bulk skill updates.

Could this be because I'm only editing part of the resource? Meaning, I'm only changing the competency attributes for one of the queues the agent is part of.

Appreciate your time. Thank you

<?php

$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<resource>

<self>https://serverip/adminapi/resource/333345</self>

<userID>333345</userID>

<firstName>John</firstName>

<lastName>Smith</lastName>

<extension>333345</extension>

<alias/>

<skillMap>

<skillCompetency>

<competencelevel>7</competencelevel>

<skillNameUriPair name="CSQ1">

<refURL>https://serverip/adminapi/skill/2</refURL>

</skillNameUriPair>

</skillCompetency>

</skillMap>

<autoAvailable>false</autoAvailable>

<type>2</type>

<team name="Team1">

<refURL>https://serverip/adminapi/team/2</refURL>

</team>

<primarySupervisorOf>

<supervisorOfTeamName name="Team1">

<refURL>https://serverip/adminapi/team/2</refURL>

</supervisorOfTeamName>

</primarySupervisorOf>

<secondarySupervisorOf/>

</resource>';

$url = "http://servername/adminapi/resource/333345";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type:application/xml"));

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

curl_setopt($ch, CURLOPT_USERPWD, "userid:pass");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);

echo($result);

curl_close($ch);

?>

***EDIT***

Got this working by modifying the CURL to the below:

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/xml"));

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");

curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);

curl_setopt($ch, CURLOPT_USERPWD, "user:password");

0 Replies 0