question

corey-tenney9911 avatar image
corey-tenney9911 asked corey-tenney9911 answered

How to update Caller-Id (Using API & Nuget pkg)

I am currently writing a utility to get the current caller-id settings for all of our extensions (1900+) and then someone will be doing some magic work in excel, and then reuploading the changes to a certain number of rows. Anyway I am just trying to update a single record at this point and here is what I have:

    CallerIdMainClass cidMC = new CallerIdMainClass();
 
    List<ByFeature> byf = new List<ByFeature>();      cidMC.byFeature = new List<ByFeature>();         if (ext.alternate != "")      {      ByFeature feat = new ByFeature();      feat.feature = "Alternate";         CallerId cid = new CallerId();      cid.type = "PhoneNumber";         PhoneInfo pi = new PhoneInfo();      pi.id = ext.alternateId;      pi.phoneNumber = ext.alternate;      pi.uri = ext.alternateUri;         cid.phoneInfo = pi;      feat.callerId = cid;         cidMC.byFeature.Add(feat);      }      cidMC.uri = "https://platform.devtest.ringcentral.com/restapi/v1.0/account/237848004/extension/237848004/caller-id";      var request = JsonConvert.SerializeObject(cidMC, Formatting.Indented);      var response = await rcClient.Extension(dr["extensionId"].ToString()).CallerId().Put(request);


request becomes this:


{ "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/237848004/extension/237848004/caller-i...;,

"byFeature": [

{


"feature": "Alternate",

"callerId": {


"type": "PhoneNumber",

"phoneInfo": {


"id": "322761004",

"uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/237848004/phone-number/322761004";,

"phoneNumber": "+13128589611"

}

}

}

]

}



However I am getting a 400 Bad Request back. What am I doing wrong?

rest apicaller id
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered
Hi Corey,

Looking at your provided request, I found some mistake in the request itself.

"phoneInfo": {
                 
              "id": "322761004",
              "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/237848004/phone-number/322761004";,
              "phoneNumber": "+13128589611"
            }
Read the API reference at update a caller ID. The phoneInfo in the update (PUT) request is an object which includes only the id parameter. The uri and the phoneNumber is not valid there.

Can you modify and give a try again.

+ Phong
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image
Tyler Liu answered
cidMC.uri = " https://platform.devtest.ringcentral.com/restapi/v1.0/account/237848004/extension/237848004/caller-i...;

You don't have to specify the uri in request body. 

I checked the API reference:  https://developer.ringcentral.com/api-docs/latest/index.html#!#RefUpdateCallerId it does say uri is a property in the request body. But the sample below doesn't have this property at all. And lots of other API calls also don't have it.
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

corey-tenney9911 avatar image
corey-tenney9911 answered
Tyler thanks for your assistance.  I changed all this today and still receive an error.  Here is the json I am sending:

    {
       "byFeature": [
        {
          "feature": "Alternate",
          "callerId": {
            "type": "PhoneNumber",
            "phoneInfo": {
              "id": "322761004"
            }
          }
        }
      ]
    }

1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image
Tyler Liu answered
Catch the exception and print the detailed error message:  https://github.com/ringcentral/ringcentral-csharp-client#exception-handling
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

corey-tenney9911 avatar image
corey-tenney9911 answered
{
  "errorCode" : "InvalidParameter",
  "message" : "Parameter [] value is invalid",
  "errors" : [ {
    "errorCode" : "CMN-101",
    "message" : "Parameter [] value is invalid",
    "parameterName" : ""
  } ],
  "parameterName" : ""
}

So what parameter am I missing?
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image
Tyler Liu answered

Frankly speaking, I don't know because the error message doesn't tell which parameter is wrong.

I check the API reference page and I found the following snippet:

{        "feature": "Alternate",        "callerId": {          "phoneInfo": { "id": "1155244004" }        } 

},

It's different from yours. Could you please remove "type": "PhoneNumber", and try again?

If it still doesn't work, please submit a help ticket and engineers there will take a look.

1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

corey-tenney9911 avatar image
corey-tenney9911 answered
That didnt work either.  I put in a support email.
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys