For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
hi every body, how can i use af:matchMediaBehavior tag in jdeveloper 12.1.3 please, I did not find any lesson to clarify its use
Have you read the documentation? https://docs.oracle.com/en/cloud/paas/mobile-cloud/mcsua/rest-connector-apis.html#GUID-12D976D7-5FCA-49C1-8D85-44A9BC438…
Have you watched the videos? https://www.youtube.com/watch?v=AzRYJ_wQduY&list=PL2ux0DjE-RYf7Rzh05Y98QWroTb76yyov
If yes can you be more specific on your question on what you don't understand please.
CM.
I have gone through the documentation and video in youtube ,but i didnt get a clear idea about the REST Connectors that created with Rest URL with headers.
I also tried the REST API (google api) provided in oracle and it is working fine.Few sample API like weather api is also working fine.
I have elaborated my question.Please check it out.
Thanks& Regards,
-Janaki
Janaki, is your question about REST Connectors in general in MCS, or specifically about adding HTTP headers to a REST Connector call via MCS?
If the later, there are 2 ways to do this:
a) For static non changing HTTP headers use the REST HTTP Header "Rules" feature:
https://docs.oracle.com/en/cloud/paas/mobile-cloud/mcsua/rest-connector-apis.html#GUID-21EBB7F1-CDD3-4812-925A-607B76A84…
b) If the HTTP headers are dynamic, instead in your NodeJS code when you call the REST connector:
service.get('/mobile/custom/incidentreport/weather/:city',
function (req, res) {
var body = {
Header: {
myHeader1:"myValue1",
myHeader2:"myValue2"
},
Body: {
GetWeather: {
CityName: req.params.city,
CountryName: 'Spain'
}
};
req.oracleMobile.connectors.post('globalweather', 'GetWeather', body).then(
function (result) {
console.info("result is: " + result.statusCode);
res.send(result.statusCode, result.result);
function (error) {
console.info("error is: " + error.statusCode);
res.send(500, error.error);
);
});
Hi Chris,
I have rest URL with authorization as one of the header parameter.When I Test the Rest Connector I am able to add the authorization as a header parameter and test it successfully.But when I test the custom API created using that connector I am getting below error.
I will also attach my Node Js code
/**
* The ExpressJS namespace.
* @external ExpressApplicationObject
* @see {@link http://expressjs.com/3x/api.html#app}
*/
* Mobile Cloud custom code service entry point.
* @param {external:ExpressApplicationObject}
* service
module.exports = function(service) {
/\*\* \* The file samples.txt in the archive that this file was packaged with contains some example code. \*/
service.get('/mobile/custom/Login_Rest/login', function(req,res) {
"content-type": req.header.content-type,
"authorization": req.header.authorization,
"Responsibility": req.header.Responsibility,
"RespApplication": req.header.RespApplication,
"SecurityGroup": req.header.SecurityGroup,
"NLSLanguage": req.header.NLSLanguage,
"Org_Id": req.header.Org_Id
username: req.params.username,
password:req.params.password
req.oracleMobile.connectors.post('TestRestAPI', '', body).then(
console.info("result is: " + result.statusCode); res.send(result.statusCode, result.result);
console.info("error is: " + error.statusCode); res.send(500, error.error);
Please clarify me below
How to pass authorization header paramter?
whether there is any error with the custom code ?
See: Calling MCS APIs from Custom Code
Note:
You might notice that you don’t need to worry about authentication when you send requests to MCS APIs from custom code. MCS re-uses the access token that’s passed into the custom code and takes care of authentication for you. With connectors, if you need to use different credentials for the external service, you can use options.externalAuthorization
options.externalAuthorization
to pass the value to be used in the Authorization
Authorization
header for the external service.
Thanks for your response Tware
Still I didn't create a custom API using REST connectors successfully.
Can you please verify the steps I follow.
Entered API name and created resources with GET method.I have given two input parameters as query and Headers parameters as headers.
My Custom code is
* The file samples.txt in the archive that this file was packaged with contains some example code.
service.get('/mobile/custom/MobileLogin_Rest/userLogin', function(req,res) {
"Content-type": req.header.content-type,
P_USRNAME: req.params.P_USRNAME,
P_PASSWORD: req.params.P_PASSWORD
And also clarify me .
Whether I have to change the authorization to options.externalAuthorization in Headers parameters?
Your code should look roughly like this:
var headers = {
req.oracleMobile.connectors.post('TestRestAPI', '', body, {inType: 'json', externalAuthorization: <authorization for your external service here if needed> }, {headers: headers}).then(
Hi Tware,
Now getting below error
Thanks,
Take a look at your logs. There should be a log message with a stack trace. That will be useful in tracking this down.
If you don't see that message, please share your identity domain name.
I found that error in log in that log.Identity Domain is gse00010158.
What is the error? Please include the stack trace.
Below is the stack trace .Please help me.
Message Text
Custom Code Problem: request: get /mobile/custom/TransRestApi/Username caused unhandled error: ReferenceError: type is not defined at /mobile/mobile_ccc/custom_code_modules/transrestapi_1.0.0_7/transrestapi/transrestapi.js:25:36 at callbacks (/mobile/mobile_ccc/mcs-node-router/node_modules/express/lib/router/index.js:164:37) at param (/mobile/mobile_ccc/mcs-node-router/node_modules/express/lib/router/index.js:138:11) at pass (/mobile/mobile_ccc/mcs-node-router/node_modules/express/lib/router/index.js:145:5) at Router._dispatch (/mobile/mobile_ccc/mcs-node-router/node_modules/express/lib/router/index.js:173:5) at Object.router (/mobile/mobile_ccc/mcs-node-router/node_modules/express/lib/router/index.js:33:10) at next (/mobile/mobile_ccc/mcs-node-router/node_modules/express/node_modules/connect/lib/proto.js:193:15) at Object.mcsSdk (/mobile/mobile_ccc/mcs-node-router/mcs-node-server-new.js:867:9) at next (/mobile/mobile_ccc/mcs-node-router/node_modules/express/node_modules/connect/lib/proto.js:193:15) at Object.methodOverride [as handle] (/mobile/mobile_ccc/mcs-node-router/node_modules/method-override/index.js:63:14) at next (/mobile/mobile_ccc/mcs-node-router/node_modules/express/node_modules/connect/lib/proto.js:193:15) at Object.urlencoded [as handle] (/mobile/mobile_ccc/mcs-node-router/node_modules/express/node_modules/connect/lib/middleware/urlencoded.js:40:37) at next (/mobile/mobile_ccc/mcs-node-router/node_modules/express/node_modules/connect/lib/proto.js:193:15) at next (/mobile/mobile_ccc/mcs-node-router/node_modules/express/node_modules/connect/lib/proto.js:195:9) at Object.json [as handle] (/mobile/mobile_ccc/mcs-node-router/node_modules/express/node_modules/connect/lib/middleware/json.js:42:37) at next (/mobile/mobile_ccc/mcs-node-router/node_modules/express/node_modules/connect/lib/proto.js:193:15)
The top line of the stack trace tells you where the problem is:
type is not defined at /mobile/mobile_ccc/custom_code_modules/transrestapi_1.0.0_7/transrestapi/transrestapi.js:25:36
Look on line 25 of transrestapi.js. Do you see "type" there. It need to be defined before you can use it.