Getting AppErrorCode: 1903 after calling CustomCode

0 votes

Hi! I'm using Unity3D 4.6.0.f1 and App42 2.9.4

I used example for CustomCode from which i downloaded from this tutorial:

http://api.shephertz.com/tutorial/Server-Side-Custom-Code/?index=customcode-wrd

In Example i does not change anything:
 

public HttpResponseObject execute(HttpRequestObject request) {
JSONObject body = request.getBody();
 
// Build Log Service For logging in Your Code
LogService logger = sp.buildLogService();
//logger.debug(" Recieved Request Body : :" + body.toString(), moduleName);
 
// Write Your Custom Code Here
// ......//
 
logger.info("Running Custom Code Hello World  ", moduleName);
 
// Create JSON Response Based on Your business logic
JSONObject jsonResponse = new JSONObject();
try {
jsonResponse.put("name", "App42CustomCodeTest");
//....//
//....//
} catch (JSONException e) {
// Do exception Handling for JSON Parsing
}
// Return JSON Response and Status Code
return new HttpResponseObject(HTTP_STATUS_SUCCESS, jsonResponse);
}


I deployed this example. And then i call this CustomCode from Unity3D.:
 

SimpleJSON.JSONClass jclass = new SimpleJSON.JSONClass();
jclass.Add ("data", data);
 
ServiceAPI sp = new ServiceAPI (Constant_App42.apiKey_App42,Constant_App42.secretKey_App42);
CustomCodeService ccs = sp.BuildCustomCodeService ();  
 
ccs.RunJavaCode("MyCustomCode", jclass, customCodeCallback); 

Sometimes it's work and i get correct response from CustomCode, but sometimes i get response with error:

successValue : {"app42Fault":{"httpErrorCode":400,"appErrorCode":1903,"message":"Bad Request","details":" Application Exception : com.shephertz.app42.paas.customcode.sample.MyCustomCode"}}

Why did i get this error? And what i need to do to escape this error?

 

asked Nov 24, 2014 in App42 Cloud API-BaaS by alexander.bargamin (16 points)
Are you able to run it from AppHQ console? Just test this from AppHQ console > Custom Code > List > Run Code and see if you are getting success response.
Application exception comes if you have some exception inside your custom code. Put some logging statements in your custom code and see what you are getting there.
I tried to run it from AppHQ console. But i got the same result: sometimes i get correct response but sometimes i get exception.

I added some logs to customCode, but when i get exception logs are not shown.
Logs are shown if i get correct response without exception.

This is my CustomCode:

public class MyCustomCode implements Executor{
   
    /**
     * Write your custom code inside this method
     */
   
    public HttpResponseObject execute(HttpRequestObject request) {
        //JSONObject body = request.getBody();
       
        ServiceAPI sp = new ServiceAPI(apiKey, secretKey);
       
         LogService logger = sp.buildLogService();
         
         logger.debug("First log", "App42Test");

        int HTTP_STATUS_SUCCESS = 200;
       
        JSONObject jsonResponse = new JSONObject();
       
        logger.debug("jsonResponse was created", "App42Test");
       
        try {
            jsonResponse.put("name", "App42CustomCodeTest");
            logger.debug("Field was added to JSON", "App42Test");
        } catch (JSONException e) {
            logger.debug("JSONException: "+e.getMessage(), "App42Test");
        }
        return new HttpResponseObject(HTTP_STATUS_SUCCESS, jsonResponse);
    }
}
mail your appname and custom code name at support@shephertz.com. we have to look at the logs  for it.

1 Answer

0 votes
Hello,

Can you please check and confirm if this has been still replicating at your end ? We had this problem earlier at our end has been fixed already early this morning.

 

Please check and let us know if it helps.

Himanshu Sharma
answered Nov 26, 2014 by hs00105 (2,005 points)
I hope your query has been resolved, kindly let us know if you have more questions for us.
Thanks,
Himanshu Sharma
Hi,
I am trying to call custom code from another custom code. Both when tested independently are running fine. But when work together gives me

Status: 400

Output: {"failure" : "true", "message" : {"app42Fault":{"httpErrorCode":400,"appErrorCode":1903,"message":"Bad Request","details":" Application Exception ","trace":"com.shephertz.app42.paas.sdk.java.customcode.CustomCodeService.runJavaCode(Ljava/lang/String;Lorg/json/JSONObject;)Lorg/json/JSONObject;"}}, "errorCode":400}

I seperatly tested output from one as input to another working fine.
Hello,

Thanks for sharing the exception message with us. We don't allow to call one custom code inside other custom code that's why you are getting this exception. You can call them separately from your client.  

Regards,
Himanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...