Resource for parameter [extensionId] is not found - SMS Send - With Password Flow

  • 1
  • Problem
  • Updated 2 months ago

Body Response:


{ "errorCode" : "CMN-102", "message" : "Resource for parameter [extensionId] is not found", "errors" : [ { "errorCode" : "CMN-102", "message" : "Resource for parameter [extensionId] is not found", "parameterName" : "extensionId" } ], "parameterName" : "extensionId" } 

Header Response:

X-Rate-Limit-Window : 60
Status_Code : 404
RoutingKey : SJC11P01PAS01
Http_Version : HTTP/1.1
Explanation : Not Found
Connection : close
Content-Language : en-US
Date : Tue, 13 Mar 2018 03:10:55 GMT
X-Rate-Limit-Group : medium
Server : nginx/1.10.2
RCRequestId : 2533297a-266c-11e8-a77d-005056bb26b9
Content-Type : application/json;charset=UTF-8
X-Rate-Limit-Limit : 40
X-Rate-Limit-Remaining : 39
Content-Length : 289

My Code:

<cfset base_url = "https://platform.devtest.ringcentral.com/restapi/"; />

<cfset authorization = setTokenType & " " & setAccessToken />

<cfset ringcentralSMS.to = "to number" />
<cfset ringcentralSMS.from = "from number" />
<cfset ringcentralSMS.text = "This is a test text." />

<cfset body = '{ "to": [{"phoneNumber": "#ringcentralSMS.to#"}], "from": {"phoneNumber": "#ringcentralSMS.from#"}, "text": "#ringcentralSMS.text#" }' />

<cfhttp
    method="post"
    url="#base_url#v1.0/account/~/extension/~/sms"
    resolveurl="no"
    getasbinary="never"
    charset="utf-8"
    
    >

<cfhttpparam type="header" name="content-type" value="application/json">
<cfhttpparam type="header" name="authorization" value="#authorization#">

<cfhttpparam type="body" value="#body#">


</cfhttp>
Photo of Jason

Jason

  • 360 Points 250 badge 2x thumb

Posted 2 months ago

  • 1
Photo of Anton Nikitin

Anton Nikitin, Official Rep

  • 2,522 Points 2k badge 2x thumb
ColdFusion server by some reason escapes tilde character so backend receives request like "/restapi/v1.0/account/%7E/extension/%7E/sms". Can you turn off escaping? 
Photo of Jason

Jason

  • 360 Points 250 badge 2x thumb
I updated the code...is it passing the tilde character now, because I'm getting this:

{ "message" : "Method Not Allowed", "errors" : [ ] } 

X-Rate-Limit-Window : 60
Status_Code : 405
RoutingKey : SJC11P01PAS01
Http_Version : HTTP/1.1
Explanation : Method Not Allowed
Connection : close
Content-Language : en-US
Date : Tue, 13 Mar 2018 20:41:25 GMT
X-Rate-Limit-Group : medium
Server : nginx/1.10.2
RCRequestId : e5a096e2-26fe-11e8-b818-005056bb26b9
Content-Type : application/json;charset=UTF-8
X-Rate-Limit-Limit : 40
X-Rate-Limit-Remaining : 39
Content-Length : 56
Photo of Anton Nikitin

Anton Nikitin, Official Rep

  • 2,522 Points 2k badge 2x thumb
OK. I feel I will need to cite the text from the link I sent in my previous message:

Let's consider a typical API resource URI:
https://platform.ringcentral.com/restapi/v1.0/account/159048008/
   extension/171857008/call-log?dateFrom=2012-08-26

The URI in the example above contains path parameters highlighted in bold. Path parameters are commonly used in the RingCentral API to identify a particular entity belonging to a given type by its unique key. Since most of the API resources represent some objects which are owned by particular a RingCentral account (company) or user, two basic path parameters are <i><b>accountId</b></i> and <i><b>extensionId</b></i>. They identify the account and extension of a RingCentral user, accordingly.

NoteNote

RingCentral users associate an account with the company main phone number and an extension with the short extension number, but both <i><b>accountId</b></i> and <i><b>extensionId</b></i> are internal identifiers.

At the same time the typical API usage scenario includes accessing particular resources on behalf of some user whose credentials (phone number, extension number and password) were passed on authentication phase. Thus in this case API enables the simplified syntax of specifying account and extension identifiers in the URI. The tilde symbol (~) can be used as a replacement for both <i><b>accountId</b></i> and <i><b>extensionId</b></i> if you are going to access data that belongs to account/extension that you are currently logged in to. Considering the example above, if the user successfully authenticated to work with account <i>159048008</i> and extension <i>171857008</i> the URI to retrieve the same resource may be written as follows:

https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~/
   call-log?dateFrom=2012-08-26
So in your case extensionId is not "101". It is internal ID which actually returned in owner_id attribute of token response (if you log in as this user). If you use main line, accountId will be the same as extensionId (but only in this particular case).

I will check what we can do to accept both escaped and unescaped tildes.
Photo of Jason

Jason

  • 360 Points 250 badge 2x thumb
It worked, once I was pointed in this direction.

AccountId and extensionId is the owner_id returned in the jSON response assuming it's the main line (such as in my case).  


That's all I care about BUT when others read this post and they want to use this information, then what would the extensionId be if you are not logged in the main line?  What if someone else reads this post and uses this code and but wants to text from a different line under the account?

I know you will say you can just the "tilde" but it didn't work for me and it won't for others in the future especially if they use Coldfusion.  

So what would one do if they want to take this advice and text from a line other than the main line?  I am asking for someone's future benefit.

Once I get this tied up, I am going to post the Coldfusion code for getting authorization and then texting.

Let me know where you want me to do it so others can benefit.
Photo of Anton Nikitin

Anton Nikitin, Official Rep

  • 2,522 Points 2k badge 2x thumb
Well, I think we will need to fix the situation with escaped tilde anyway. Your situation is pretty unusual, I have not heard about anybody having the same problem before. 

But, if you look over the Internet, you will find that this is actually a buggy behavior of ColdFusion which violates most recent RFCs (see http://web.archive.org/web/20110102120715/http://cookbooks.adobe.com/post_URL_encoding_to_RFC_3986-1...)

So if you write the app to be used for your own account only, we can provide you with your accountId. If you write a public app which can work with different accounts it won't work. And I can't tell you how to work this problem around until we support escaped tildes.

I wonder if you can connect to Adobe support and ask them about this issue (as well as one with redirect processing). Maybe there are some updates you can install to fix the issue.
Photo of Jason

Jason

  • 360 Points 250 badge 2x thumb
I am not encoding my URL, because your system does not ask for that, so that article is talking about using a function that I am not using.  

That article is not relevant.
Photo of Anton Nikitin

Anton Nikitin, Official Rep

  • 2,522 Points 2k badge 2x thumb
I guess that internally they use the same function.