Legacy Dev Forum Posts

 View Only

Sign Up

405 response for PUT /api/v2/externalcontacts/contacts/{contactId}

  • 1.  405 response for PUT /api/v2/externalcontacts/contacts/{contactId}

    Posted 06-05-2025 18:16

    nrajan | 2020-01-23 00:09:25 UTC | #1

    Hi all, this code snippet is returning a 405 error for me. I am somewhat new to working with rest APIs and HTTP, so please excuse me if my error is not purecloud specific.

    See node snippet (doesn't run by itself) :

    //body.entities[0].id is the contactId of the 0th element of the entities list in the response of GET // https://api.mypurecloud.com/api/v2/externalcontacts/contacts?pageSize=${pageSize}&pageNumber=${pageNumber}&q=${q} // where pageSize = 1, pageNumber = 1, and q = phone# from our db

    let contactId = body.entities[0].id;

    let fullurl = https://api.mypurecloud.com/api/v2/externalcontacts/contacts/${contactId};

    // obj to send as request body let updateContactObj = {}; updateContactObj.firstName = recordset[i].firstname; // required field updateContactObj.lastName = recordset[i].lastname; // required field updateContactObj.externalSystemUrl = externalLink; // field to update

    let options = { url: fullUrl, method: "PUT", headers: { 'Authorization': auth.tokentype + " " + auth.accesstoken, 'Content-Type': "application/json" }, body: JSON.stringify(updateContactObj) }

    // response status is 405 request(options, function (error, response, body) {

    console.log("Contact Updated") console.log(body); console.log(error)

    });


    tim.smith | 2020-01-23 16:19:58 UTC | #2

    405 means that PUT isn't allowed on the URL you're requesting. PUT /api/v2/externalcontacts/contacts/{contactId} is a valid resource, so my guess is that your request URL is becoming malformed in some way. From the code you shared, I'd guess that the contact ID is empty, which would make the request URL /api/v2/externalcontacts/contacts/, which is not a valid path.


    nrajan | 2020-02-07 20:21:35 UTC | #3

    Thanks Tim, I missed your reply. I set up better error checking in my script and I think I fixed it.


    system | 2020-03-09 20:21:38 UTC | #4

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 6945