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

  • 1
  • Problem
  • Updated 9 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

  • 450 Points 250 badge 2x thumb

Posted 9 months ago

  • 1
Photo of Anton Nikitin

Anton Nikitin, Official Rep

  • 2,934 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

  • 450 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,612 Points 2k badge 2x thumb
Apparently because you are sending something like "POST /restapi/v1.0/account/&" which doesn't exist. I would recommend you to check raw API request/response before asking in order make it more efficient.
Photo of Jason

Jason

  • 450 Points 250 badge 2x thumb
Ok, my link is outputted by my server when it builds the link and it looks like this before it's used to make the request from your server:

https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/101/sms

Are you saying I have the wrong link to send an SMS? Are you saying it's still escaping the tilde?  

What is the account or account_Id and where do I find that in my Developer Console and User Account, so I can remove the tilde and see if that's the problem.    That might be a workaround anyways.  To be frank, it's cleaner code when you are more specific in requests, so it might be better to remove the tilde from the process anyways.

Please understand I making headway on Coldfusion and I am going to have working code that others can use.  

Authorization on Password Flow is working on Coldfusion.

I just need help to get this done...
Photo of Anton Nikitin

Anton Nikitin, Official Rep

  • 2,612 Points 2k badge 2x thumb
You can use tilde if you manage to avoid escaping it by CF. And you can use it instead of both "accountId" and "extensionId" as explained here https://developer.ringcentral.com/api-docs/latest/index.html#!#Resources.html

So your request should look like 

POST https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/sms
Photo of Jason

Jason

  • 450 Points 250 badge 2x thumb
Ok.  Then I have it correct, but on your end the tilde is not being escaped by Coldfusion regardless of what I do, because I am still getting the same error.  By the way, I have never had Coldfusion alter a link....I test the output before it's submitted the RC and it looks identical to the above.

So I need to remove the "tilde" from the equation.  From what I can tell the the account is the "owner_id" which is returned in the jSON response with the token response.  I need someone to confirm that, because everytime someone asks on these forums, the response is "use the tilde" instead.  

Assuming that's correct:

https://platform.devtest.ringcentral.com/restapi/v1.0/account/[OWNER_IDFROMJSONRESPONSE/extension/101/sms

The extension is 101 which is the main line so I know that's right and I am still getting the the same error (so know with or without the tilde):

RESPONSE BODY:

{ "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" } 

RESPONSE HEADER:

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 : Wed, 14 Mar 2018 01:40:38 GMT
X-Rate-Limit-Group : medium
Server : nginx/1.10.2
RCRequestId : b26c45c6-2728-11e8-ae0d-005056bb26b9
Content-Type : application/json;charset=UTF-8
X-Rate-Limit-Limit : 40
X-Rate-Limit-Remaining : 39
Content-Length : 289
Photo of Anton Nikitin

Anton Nikitin, Official Rep

  • 2,612 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

  • 450 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,612 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

  • 450 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,612 Points 2k badge 2x thumb
I guess that internally they use the same function.