Not able to access Coldfusion Rest Service through website url - Coldfusion - rest

My coldfusion version is 10 and configured with iis. I have configured Rest service using the following code
<cfset restInitApplication(getDirectoryFromPath(getCurrentTemplatePath()), "myservicename") />
My cfc which is in same directory looks something like that
component restpath="test" rest="true" produces="application/json"
{
remote array function getResult(
required string tmpID restargsource="path",
string startDate restargsource="query",
string endDate restargsource="query"
)
httpmethod="GET"
restpath="{tmpID}"
{
return arguments.tmpID;
}
}
I am trying to access the rest service by url but it is giving me 404 not found error. Here is url which i have tried.
http://localhost:8500/rest/myservicename/test/10221
http://example.com/rest/myservicename/test/10221
http://127.0.0.1/rest/myservicename/test/10221
But all three is not working for me. When i try to refresh the service from coldfusion administrator, it is giving me following error.
Unable to refresh REST service.
Application myservicename could not be initialized.
Reason: The application does not contain any rest enabled CFCs.
The application does not contain any rest enabled CFCs.
I have save my cfc to webroot of iis and update the root path of rest service through coldfusion administrator. Then above error is gone and got the green message 'Server has been updated successfully'. But still not accessible through any url. Still getting 404 error. Can any one point me where i am doing wrong? Or help me to resolve this issue.

Related

Getting a Code: 503 error in running Watson Speech to Text API

I have been using the Watson API for a long time now, however it has started giving me Code:503 errors recently for the past 4 days and I am rarely able to get the desired output which I used to. The code works fine and is unchanged.
This is the error I am receving.
watson_developer_cloud.watson_service.WatsonApiException: Error: <HTML><HEAD>
<TITLE>Internal Server Error</TITLE>
</HEAD><BODY>
<H1>Internal Server Error - Write</H1>
The server encountered an internal error or misconfiguration and was unable to
complete your request.<P>
Reference #4.327f1cb8.1597063995.c75870b
</BODY></HTML>
, Code: 503
Is it because of the overload on IBM cloud during the past couple of days or is there any network issues at my end?
I had the same issue, I was using NodeJS and adding an extra "/" at the end of the URL seemed to work from the example found here:
https://cloud.ibm.com/apidocs/speech-to-text?code=node#recognize
const speechToText = new SpeechToTextV1({
authenticator: new IamAuthenticator({
apikey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
}),
serviceUrl: 'https://api.us-east.speech-to-text.watson.cloud.ibm.com/instances/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/',
});
^Note the extra "/" at the end of service URL

Yahoo social/contacts api -> update contact (PUT method)

So.. The application I wrote ages ago to update yahoo contacts seems to have quit working... It was using oauth1 to authenticate...
doing a PUT to http://social.yahooapis.com/v1/user/me/contacts
gets me a 404 Not Found on Accelerator error
<!-- status code : 404 -->
<!-- Not Found on Accelerator -->
<!-- host machine: e20.ycpi.cha.yahoo.com -->
<!-- timestamp: 1506448562.000 -->
<!-- url: http://social.yahooapis.com/v1/user/me/contacts-->
Thinking the issue may be their oauth1 api.. I switched to oauth2
same error
So I try http://social.yahooapis.com/v1/user/me/contacts (httpS)
I get
401 You are unauthorized for this operation
I'm using scope sdct-w (https://developer.yahoo.com/oauth2/guide/yahoo_scopes/)
Is Yahoo Contacts API dead or am I doing something wrong?
https://social.yahooapis.com/v1/user/{guid}/contacts
a) the endpoint is now https (documentation still shows http)
b) used to be able to use "me" for the {guid} ... this is no longer the case
You have to add access token on your request.
Try:
https://social.yahooapis.com/v1/user/me/contacts?access_token=${access_token}&format=json

coldfusion REST service, 404 not found

I cannot seem to get my REST service to work... I get a 404 when I call the URL.
Im running Win 7, CF 10 developer, Apache webserver. I've developed on this for years, so the setup works - but this is my first go at REST services thru CF... I mention that because CF is working, the dir and webserver are working etc.
Directory looks like this
C:\wwwroot\restTest
CODE - saved as "obj1.cfc" - ( Note: I've tried restpath with and without the / )
<cfcomponent restpath="/restTest" rest="true" >
<cffunction name="getMethod" access="remote" returntype="String" httpmethod="GET" >
<cfreturn "this is a string returned" />
</cffunction>
</cfcomponent>
The coldfusion ADMIN setup looks like this
Root path: 'C:\wwwroot\restTest'
Service Mapping: 'test'
I'm using the service mapping because I don't have an associated application name - no Application.cfc - I was trying to keep this super simple.
I get a green 'success' message when I set that path
Browse to -
127.0.0.1/rest/test/restTest/
result - 404
What am I doing wrong? It is my understanding that "/rest/" is a default mapped path in CF for routing the service - I may be wrong, but I know I read it somewhere - and the examples all use it. I also believe I can change that either in the admin or in some XML file...
Turns out - Apache needed this line added to the host (or globally in the config)
JkMountFile "C:/ColdFusion10/config/wsconfig/1/uriworkermap.properties"
Once I added that... all was good.

REST services do not work in custom mapped directory on Coldfusion 10 server

I am new to REST API. I am trying to convert web application to REST-ful with an updated site design.
My work environment on development server is Coldfusion10, Windows 2008 R2 Server.
So far I successfully registered REST services to web root directory of ColdFusion 10 server and it works fine.
However, I need to register REST services in the site's directory. I have done so and it worked couple of times but, most of the time I am receiving 500 error after I edit the CFC (changing string in cfreturn from "foo" to "foo2"). I verified syntax of the CFC by going directly via url and, its ok.
I tried to add REST services in Administrator and, most of the time I get errors when adding in Administrator like this:
•Unable to refresh REST service.
Application rc could not be initialized.
Reason: The application does not contain any rest enabled CFCs.
The application does not contain any rest enabled CFCs.
I added web services in the Application.cfc
<cfcomponent output="false">
<cfset this.name = hash(getCurrentTemplatePath()) />
<cfset this.applicationTimeout = createTimeSpan( 0, 0, 1, 0 ) />
<cffunction name="onRequestStart" access="public" returntype="boolean" output="false" hint="I initialize the request.">
<cfset restInitApplication("E:\flex\html\v4\rc","rc")>
<cfreturn true />
</cffunction>
</cfcomponent>
This is the /rc/studentHandler.cfc
<cfcomponent restpath="student" rest="true">
<cffunction name="getMethod" access="remote" output="false" returntype="string" httpmethod="get">
<cfreturn "foo">
</cffunction>
</cfcomponent>
And the last file is student.cfm. I call it from http://mydevip/v4/student.cfm
<cfhttp url="http://mydevip/rest/rc/student" method="get">
<cfoutput>#cfhttp.filecontent#</cfoutput>
I tried to call cfc directly from url which works if cfc in the CF web root folder http://mydevip/rest/rc/student and, gives me error if I call cfc in custom directory.
Here is the error from application.log
"Error","ajp-bio-8012-exec-5","11/13/13","10:13:30","5C89BF4E37081433800CEF0D961170B0","object is not an instance of declaring class The specific sequence of files included or processed is: E:\flex\html\v4\rc\studentHandler.cfc'' "
Thanks,
Gena

Getting an error while invoking a REST service using Javascript

I have developed a REST Web service to get resources, I am able to access it through Java/Spring Template and even the xml response is coming if I type the URI on browser.
But when I invoke the same URI using XMLHttpRequest in Java script I am getting the below error.
"XMLHttpRequest cannot load URI(actual uri with server name ..etc) . Origin file:// is not allowed by Access-Control-Allow-Origin."
Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101.
My JS code is as below.
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", "http://localhost:8080/rest/apps", false );
xmlHttp.send( null );
Please let me know what would be the problem and help me to resolve this.
Regards,
Sreedhar
here Origin is the local file system, that you're loading the HTML page, that load call via a file:/// . the request is from the same origin. If you're trying to load from somewhere else then you will not get the Error.
Check For this answer