Custom Cloud Service

Through Cloud Code service a developer can deploy and run their custom code on our servers without worrying about scalability, security and reliability. App42 Cloud Code platform applies multiple securities and scalability features to your code on the fly. Since any developer can upload Custom/Cloud Code, the lifecycle of the cloud code is managed in sandbox by the platform, which in turn puts some guidelines on the developer.

The code can be used to put validation and custom logic on developer’s data that developers want to run on the server instead of client side. Custom/Cloud Code can include App42 APIs inside it, and can be used to aggregate/mash two or more App42 services into their own cloud code.

Cloud code allows to create their own APIs and hence extend the rich set of 750+ APIs that App42 already offers. It can be scheduled for any future date, time and timezone and can be run from the API itself as well as AppHQ Management Console. Once the code is deployed, the developer can access deployed service using REST or thought native SDKs supported by App42.

Import Statement
  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
import com.shephertz.app42.paas.sdk.android.App42API;
import com.shephertz.app42.paas.sdk.android.App42Response;
import com.shephertz.app42.paas.sdk.android.App42Exception;
import com.shephertz.app42.paas.sdk.android.App42BadParameterException;
import com.shephertz.app42.paas.sdk.android.App42NotFoundException;
import com.shephertz.app42.paas.sdk.android.customcode.CustomCodeService;
using com.shephertz.app42.paas.sdk.windows;  
using com.shephertz.app42.paas.sdk.windows.customcode;   
#import "Shephertz_App42_iOS_API/Shephertz_App42_iOS_API.h"   
#import<Shephertz_App42_iOS_API/Shephertz_App42_iOS_API.h>
import com.shephertz.app42.paas.sdk.java.App42API;
import com.shephertz.app42.paas.sdk.java.App42Response;
import com.shephertz.app42.paas.sdk.java.App42Exception;
import com.shephertz.app42.paas.sdk.java.App42BadParameterException;
import com.shephertz.app42.paas.sdk.java.App42NotFoundException;
import com.shephertz.app42.paas.sdk.java.customcode.CustomCodeService;
using com.shephertz.app42.paas.sdk.csharp;  
using com.shephertz.app42.paas.sdk.csharp.customcode;  
<script type="text/javascript" src="App42-all-x.x.x.min.js"></script>
local App42API = require("App42-Lua-API.App42API")
local JSON = require("App42-Lua-API.JSON") 
#include "App42API.h"
using com.shephertz.app42.paas.sdk.csharp;  
using com.shephertz.app42.paas.sdk.csharp.customcode;  
Not Available
#include "App42API.h"
Not Available
import com.shephertz.app42.paas.sdk.as3.App42CallBack;
import com.shephertz.app42.paas.sdk.as3.App42Exception;
import com.shephertz.app42.paas.sdk.as3.ServiceAPI;
import com.shephertz.app42.paas.sdk.as3.customcode.CustomCodeService;
import com.shephertz.app42.paas.sdk.as3.util.Util;
Coming Soon
import com.shephertz.app42.paas.sdk.jme.App42API;
import com.shephertz.app42.paas.sdk.jme.App42Response;
import com.shephertz.app42.paas.sdk.jme.App42Exception;
import com.shephertz.app42.paas.sdk.jme.App42BadParameterException;
import com.shephertz.app42.paas.sdk.jme.App42NotFoundException;
import com.shephertz.app42.paas.sdk.jme.customcode.CustomCodeService;
Initialize

In order to use the various functions available in a specific API, a developer has to initialize with App42API by passing the apiKey and the secretKey which will become available after the app creation from AppHQ dashboard.

Required Parameters

apiKey - The Application key given when the app was created. secretKey - The secret key corresponding to the application key given when the app was created.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
App42API.Initialize("API_KEY","SECRET_KEY");
[App42API initializeWithAPIKey:@"APP_KEY" andSecretKey:@"SECRET_KEY"]; 
App42API.initializeWithAPIKey("API_KEY", andSecretKey:"SECRET_KEY")    
App42API.initialize("API_KEY","SECRET_KEY");
App42API.Initialize("API_KEY","SECRET_KEY");
App42.initialize("API_KEY","SECRET_KEY");
App42API:initialize("API_KEY","SECRET_KEY")
App42API::Initialize("API_KEY", "SECRET_KEY");
App42API.Initialize("API_KEY","SECRET_KEY");
Not Available
App42API::Initialize("API_KEY", "SECRET_KEY");
Not Available
var api:ServiceAPI = new ServiceAPI("API_KEY","SECRET_KEY");
Coming Soon
App42API.initialize("API_KEY","SECRET_KEY");
Build Service

After initialization, the developer will have to call the buildXXXService method on App42API to get the instance of the particular API that they wish to build. For example, to build an instance of CustomCodeService, buildCustomCodeService() method needs to be called.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
CustomCodeService customCodeService = App42API.buildCustomCodeService(); 
CustomCodeService customCodeService = App42API.BuildCustomCodeService();  
CustomCodeService *customCodeService = [App42API buildCustomCodeService]; 
let customcodeService = App42API.buildCustomCodeService() as? CustomCodeService    
CustomCodeService customCodeService = App42API.buildCustomCodeService(); 
CustomCodeService customCodeService = App42API.BuildCustomCodeService(); 
var customCodeService  = new App42CustomCodeService();
local customCodeService = App42API:buildCustomCodeService()
CustomCodeService *customCodeService = App42API::BuildCustomCodeService();
CustomCodeService customCodeService = App42API.BuildCustomCodeService(); 
CustomCodeService *customCodeService = App42API::BuildCustomCodeService();
Not Available
Not Available
var customcodeService:CustomCodeService = api.buildCustomCodeService();
Coming Soon
CustomCodeService customCodeService = App42API.buildCustomCodeService(); 
Deploy Jar File

Deploy Custom code in App42 Cloud.

Required Parameters

name - Name of Custom Code Service to be deployed. jarFilePath - Custom code jar file path.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
String nameOfCustomCodeService = "DEPLOYED_CUSTOM_CODE_NAME";
String jarFilePath = "JAR FILE PATH";
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.buildCustomCodeService(); 
customCode.deployJarFile(nameOfCustomCodeService, jarFilePath,new App42CallBack() {
public void onSuccess(Object response)
{
    String  res = (String)response;      
	System.out.println("response is " + res) ;
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
Coming Soon
Not Available
Coming Soon
String nameOfCustomCodeService = "DEPLOYED_CUSTOM_CODE_NAME";
String jarFilePath = "JAR FILE PATH";
App42API.initialize("API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.buildCustomCodeService(); 
String res = customCodeService.deployJarFile(nameOfCustomCodeService, jarFilePath);
System.out.println("response is " + res) ;
Coming Soon
Not Available
Coming Soon
Not Available
Coming Soon
Not Available
Not Available
Not Available
Coming Soon 
Coming Soon
Coming Soon
Undeploy Jar File

Undeploy Java Code deployed in App42 Cloud.

Required Parameters

name - Name of Custom Code Service to be undeployed.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
String nameOfCustomCodeService = "DEPLOYED_CUSTOM_CODE_NAME";
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.buildCustomCodeService(); 
customCode.undeployJarFile(nameOfCustomCodeService, new App42CallBack() {
public void onSuccess(Object response) 
{
	String  res = (String)response;      
	System.out.println("response is " + res);
}
public void onException(Exception ex)
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
Not Available
Not Available
Coming Soon
String nameOfCustomCodeService = "DEPLOYED_CUSTOM_CODE_NAME";
App42API.initialize("API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.buildCustomCodeService(); 
String res = customCodeService.undeployJarFile(nameOfCustomCodeService);
System.out.println("response is " + res);
Not Available 
Not Available
Coming Soon
Not Available
Not Available
Not Available
Not Available
Not Available
Coming Soon 
Coming Soon
Not Available
Run Java Code

Run custom code deployed in the App42 Cloud.

Required Parameters

name - Name of deployed CustomCode Service. jsonBody - Request Body in JSON format.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
String name = "DEPLOYED_CUSTOM_CODE_NAME";
JSONObject jsonBody = new JSONObject();
jsonBody.put("Company", "Shephertz");
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.buildCustomCodeService(); 
customCode.runJavaCode(name,jsonBody,new App42CallBack() {
public void onSuccess(Object response) 
{
	JSONObject  res= (JSONObject)response;      
	System.out.println("response is " + res) ;
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
String name = "DEPLOYED_CUSTOM_CODE_NAME";
JObject jsonBody = new JObject();
jsonBody.Add("Company", "Shephertz");
App42API.Initialize("API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.BuildCustomCodeService();  
customCodeService.RunJavaCode(name, jsonBody, new Callback());  
public class Callback : App42Callback  
{  
	public void OnException(App42Exception exception)  
	{  
		Console.WriteLine("Exception Message : " + exception);  
	}  
	public void OnSuccess(Object response)  
	{  
		 JObject json = (JObject) response;     
		 String jsonResponse = json.ToString();  
    }  
} 
NSString *name = @"DEPLOYED_CUSTOM_CODE_NAME"; 
NSDictionary *requestBody = [NSDictionary dictionaryWithObjectsAndKeys:@"Company",@"Shephertz", nil];
[App42API initializeWithAPIKey:@"APP_KEY" andSecretKey:@"SECRET_KEY"]; 
CustomCodeService *customCodeService = [App42API buildCustomCodeService]; 
[customCodeService runJavaCode:name requestBody:requestBody completionBlock:^(BOOL success, id responseObj, App42Exception *exception) 
{
	if (success)
	{
		NSLog(@"Response is = %@",responseObj);
	}
	else
	{
		NSLog(@"Exception = %@",[exception reason]);
		NSLog(@"HTTP error Code = %d",[exception httpErrorCode]);
		NSLog(@"App Error Code = %d",[exception appErrorCode]);
		NSLog(@"User Info = %@",[exception userInfo]);
	}
}];  
let name = "DEPLOYED_CUSTOM_CODE_NAME"
let requestBody = NSMutableDictionary()
requestBody["Company"] = "Shephertz"
App42API.initializeWithAPIKey("API_KEY" andSecretKey:"SECRET_KEY")    
let customCodeService = App42API.buildCustomCodeService() as? CustomCodeService  
customCodeService?.runJavaCode(name, requestBody: requestBody as [NSObject : AnyObject],  completionBlock: { (success, response, exception) -> Void in
	if(success)
	{
        let responseString = response as! NSString
		NSLog("Success Response  is %@", responseString)
	}
	else
	{
		NSLog("%@", exception.reason!)
		NSLog("%d", exception.appErrorCode)
		NSLog("%d", exception.httpErrorCode)
		NSLog("%@", exception.userInfo!)
	}
})
String name = "DEPLOYED_CUSTOM_CODE_NAME";
JSONObject jsonBody = new JSONObject();
jsonBody.put("Company", "Shephertz");
App42API.initialize("API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.buildCustomCodeService(); 
JSONObject response = customCodeService.runJavaCode(name, jsonBody);
System.out.println("response is " + response);	
String name = "DEPLOYED_CUSTOM_CODE_NAME";
JSONClass  jsonBody = new JSONClass ();
jsonBody.Add("Company", "Shephertz");
App42Log.SetDebug(true);		//Print output in your editor console
App42API.Initialize("API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.BuildCustomCodeService(); 
customCodeService.RunJavaCode(name, jsonBody, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		JSONClass  objecti = (JSONClass )response;
		App42Log.Console("objectName is : " + objecti["name"]);
		App42Log.Console("Success : " + response);
	}

	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
var name = "DEPLOYED_CUSTOM_CODE_NAME";
var jsonBody = {"Company":"Shephertz"};
var emailId = "nick@shephertz.co.in";
var result;
App42.initialize("API_KEY", "SECRET_KEY");
var customCodeService = new App42CustomCodeService();
customCodeService.runJavaCode(name, jsonBody, {
	success: function (object) {
		var customCodeObj = JSON.parse(object);
		console.log("Success Response " , customCodeObj)
	},
	error: function (error) {
	}
});
local name = "DEPLOYED_CUSTOM_CODE_NAME"
local jsonBody = {}
jsonBody.Company = "Shephertz"
local App42CallBack = {}
App42API:initialize("API_KEY","SECRET_KEY")
local customCodeService = App42API:buildCustomCodeService()
customCodeService:runJavaCode(name, jsonBody,App42CallBack)
function App42CallBack:onSuccess(object)
	  print(JSON:encode(object))  
end
function App42CallBack:onException(exception)
	print("Message is : "..exception:getMessage())
	print("App Error code is : "..exception:getAppErrorCode())
	print("Http Error code is "..exception:getHttpErrorCode())
	print("Detail is : "..exception:getDetails())
end
const char* name = "DEPLOYED_CUSTOM_CODE_NAME";
App42Object *object = new App42Object();
object->setObject("Company", "Shephertz");
App42API::Initialize("API_KEY", "SECRET_KEY");
CustomCodeService *customCodeService = App42API::BuildCustomCodeService();
customCodeService->RunJavaCode(name, object,  app42callback(Sample_Class::onCustomCodeServiceRequestCompleted, this));
void Sample_Class::onCustomCodeServiceRequestCompleted(void *response)
{
    App42CustomCodeResponse *customCodeResponse = (App42CustomCodeResponse*)response;
    if(customCodeResponse->isSuccess)
    {
        printf("\n code=%d",customCodeResponse->getCode());
        printf("\n isSuccess=%d",customCodeResponse->isSuccess);
        printf("\n Response Body=%s",customCodeResponse->getBody().c_str());
    }
    else
    {
        printf("\nerrordetails:%s",customCodeResponse->errorDetails.c_str());
        printf("\nerrorMessage:%s",customCodeResponse->errorMessage.c_str());
        printf("\nappErrorCode:%d",customCodeResponse->appErrorCode);
        printf("\nhttpErrorCode:%d",customCodeResponse->httpErrorCode);
    }
}
String name = "DEPLOYED_CUSTOM_CODE_NAME";
JSONClass  jsonBody = new JSONClass ();
jsonBody.Add("Company", "Shephertz");
App42API.Initialize("API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.BuildCustomCodeService(); 
JSONClass  response = customCodeService.RunJavaCode(name, jsonBody);
Console.WriteLine("response is " + response);	
const char* name = "DEPLOYED_CUSTOM_CODE_NAME";
App42Object *object = new App42Object();
object->setObject("Company", "Shephertz");
App42API::Initialize("API_KEY", "SECRET_KEY");
CustomCodeService *customCodeService = App42API::BuildCustomCodeService();
customCodeService->RunJavaCode(name, object, this, app42callfuncND_selector(Sample_Class::onCustomCodeServiceRequestCompleted));
void Sample_Class::onCustomCodeServiceRequestCompleted(App42CallBack *sender, void *response)
{
    App42CustomCodeResponse *customCodeResponse = (App42CustomCodeResponse*)response;
    if(customCodeResponse->isSuccess)
    {
        printf("\n code=%d",customCodeResponse->getCode());
        printf("\n isSuccess=%d",customCodeResponse->isSuccess);
        printf("\n Response Body=%s",customCodeResponse->getBody().c_str());
    }
    else
    {
        printf("\nerrordetails:%s",customCodeResponse->errorDetails.c_str());
        printf("\nerrorMessage:%s",customCodeResponse->errorMessage.c_str());
        printf("\nappErrorCode:%d",customCodeResponse->appErrorCode);
        printf("\nhttpErrorCode:%d",customCodeResponse->httpErrorCode);
    }
}
Not Available
Not Available
var name:String = "DEPLOYED_CUSTOM_CODE_NAME";  
var jsonObject:Object = new Object;
jsonObject.Company = "Shephertz";
var api:ServiceAPI = new ServiceAPI("API_KEY","SECRET_KEY");
var customcodeService:CustomCodeService = api.buildCustomCodeService();
customcodeService.runJavaCode(name,jsonObject,new callback()); 
public class callback implements App42CallBack  
{  
	public function onException(exception:App42Exception):void  
	{  
		trace("Exception Message " + exception);  
	}  
	public function onSuccess(response:Object):void  
	{  
		trace("Response is :" + Util.toString(response));
		trace("Object Name is:" + Util.toString(response.name));
	}  
}
Coming Soon
String name = "DEPLOYED_CUSTOM_CODE_NAME";
JSONObject jsonBody = new JSONObject();
jsonBody.put("Company", "Shephertz");
App42API.initialize("API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.buildCustomCodeService(); 
JSONObject response = customCodeService.runJavaCode(name, jsonBody);
System.out.println("response is " + response);
Exception Handling

The functions available under Custom Code API can throw some exceptions in abnormal conditions. For example, if you are trying to deploy the custom code with the name that already exists, you will get an appErrorCode as 1902 stating that Invalid JSON in the request body.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
String name = "DEPLOYED_CUSTOM_CODE_NAME";
JSONObject jsonBody = new JSONObject();
jsonBody.put("Company", "Shephertz");
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.buildCustomCodeService(); 
customCode.runJavaCode(name , jsonBody,new App42CallBack() {
public void onSuccess(Object response) 
{
	JSONObject  res= (JSONObject)response;      
	System.out.println("response is " + res) ;
}
public void onException(Exception ex) 
{
	App42Exception exception = (App42Exception)ex;
	int appErrorCode = exception.getAppErrorCode();
	int httpErrorCode = exception.getHttpErrorCode();
	if(exception.getAppErrorCode() == 1902) 
	{
	//Handle here for Bad Request (Invalid JSON in request body.)
	}
	else if(exception.getAppErrorCode() == 1900) 
	{
	//Handle here for Bad Request (Jar File contains the invalid content or class usage that is not allowed for deployment)
	//Example of it using System class or putting .sh/.dll file inside jar file
	}
	else if(exception.getAppErrorCode() == 1401)  
	{  
	// handle here for Client is not authorized  
	}  
	else if(exception.getAppErrorCode() == 1500)  
	{  
	// handle here for Internal Server Error  
	}  
	String jsonText = ex.getMessage(); /* returns the Exception text in JSON format. (as shown below)*/ 
	}	   
});                                        
String name = "DEPLOYED_CUSTOM_CODE_NAME";
JObject jsonBody = new JObject();
jsonBody.Add("Company", "Shephertz");
App42API.Initialize("API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.BuildCustomCodeService();  
customCodeService.RunJavaCode(name, jsonBody, new Callback());  
public class Callback : App42Callback  
{  
	public void OnException(App42Exception exception)  
	{  
		Console.WriteLine("Exception Message : " + exception);  
		int appErrorCode = ex.GetAppErrorCode();
		int httpErrorCode = ex.GetHttpErrorCode();
		if(ex.getAppErrorCode() == 1902) 
		{
			//Handle here for Bad Request (Invalid JSON in request body.)
		}
		else if(ex.getAppErrorCode() == 1900) 
		{
			//Handle here for Bad Request (Jar File contains the invalid content or class usage that is not allowed for deployment)
			//Example of it using System class or putting .sh/.dll file inside jar file
		}
		else if(ex.getAppErrorCode() == 1401)  
		{  
			// handle here for Client is not authorized  
		}  
		else if(ex.getAppErrorCode() == 1500)  
		{  
			// handle here for Internal Server Error  
		}  
		String jsonText = ex.GetMessage(); 
	}  
	public void OnSuccess(Object response)  
	{ 
		JObject json  = (JObject) response;
		Console.WriteLine("response is : " + json);
	} 
}  
					
NSString *name = @"DEPLOYED_CUSTOM_CODE_NAME"; 
NSDictionary *requestBody = [NSDictionary dictionaryWithObjectsAndKeys:@"John",@"name", nil];
[App42API initializeWithAPIKey:@"APP_KEY" andSecretKey:@"SECRET_KEY"]; 
CustomCodeService *customCodeService = [App42API buildCustomCodeService]; 
[customCodeService runJavaCode:name requestBody:requestBody completionBlock:^(BOOL success, id responseObj, App42Exception *exception) 
{
	if (success)
	{
		App42Response *response =(App42Response*)responseObj;
		NSString *jsonResponse = [response toString]; 
	}
	else
	{
		int appErrorCode = exception.appErrorCode;
		int httpErrorCode = exception.httpErrorCode;
		if(appErrorCode == 1902)
		{
			//Handle here for Bad Request (Invalid JSON in request body.)
		}
		else if(appErrorCode == 1900) 
		{
			//Handle here for Bad Request (Jar File contains the invalid content or class usage that is not allowed for deployment)
			//Example of it using System class or putting .sh/.dll file inside jar file
		}
		else if(appErrorCode == 1401){
			// handle here for Client is not authorized
		}
		else if(appErrorCode == 1500){
			// handle here for Internal Server Error
		}
		NSString *jsonText = exception.reason; 	
	} 
}];	
coming soon
String name = "DEPLOYED_CUSTOM_CODE_NAME";
JSONObject jsonBody = new JSONObject();
jsonBody.put("Company", "Shephertz");
App42API.initialize("API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.buildCustomCodeService(); 
try 
{
	customCodeService.runJavaCode(name, jsonBody);
} 
catch (App42Exception ex) {
	int appErrorCode = ex.getAppErrorCode();
	int httpErrorCode = ex.getHttpErrorCode();
	if(ex.getAppErrorCode() == 1902) 
	{
		//Handle here for Bad Request (Invalid JSON in request body.)
	}
	else if(ex.getAppErrorCode() == 1900) 
	{
		//Handle here for Bad Request (Jar File contains the invalid content or class usage that is not allowed for deployment)
		//Example of it using System class or putting .sh/.dll file inside jar file
	}
	else if(ex.getAppErrorCode() == 1401)  
    {  
        // handle here for Client is not authorized  
    }  
    else if(ex.getAppErrorCode() == 1500)  
    {  
        // handle here for Internal Server Error  
    }  
    String jsonText = ex.getMessage(); /* returns the Exception text in JSON format. (as shown below)*/ 
}	  
String name = "DEPLOYED_CUSTOM_CODE_NAME";
JSONClass  jsonBody = new JSONClass ();
jsonBody.Add("Company", "Shephertz");
App42Log.SetDebug(true);		//Print output in your editor console
App42API.Initialize("API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.BuildCustomCodeService(); 
customCodeService.RunJavaCode(name, jsonBody, new UnityCallBack());
public class UnityCallBack : App42CallBack
{
    
	public void OnException(Exception e)
	{
		App42Exception ex = (App42Exception)e;
		int appErrorCode = ex.GetAppErrorCode();
        int httpErrorCode = ex.GetHttpErrorCode();
	if(appErrorCode == 1902)
	{
		//Handle here for Bad Request (Invalid JSON in request body.)
	}
	else if(appErrorCode  == 1900)
	{
		//Handle here for Bad Request (Jar File contains the invalid content or class usage that is not allowed for deployment)
		//Example of it using System class or putting .sh/.dll file inside jar file
	}
	else if(appErrorCode == 1401)
	{
		// handle here for Client is not authorized
	}
	else if(appErrorCode == 1500)
	{
		// handle here for Internal Server Error
	}
	String jsonText = ex.GetMessage(); 
	}
    
    public void OnSuccess(object response)
    {
		App42Log.Console("Response is :" + response.ToString());
	}
}
Not Available
local name = "DEPLOYED_CUSTOM_CODE_NAME"
local jsonBody = {}
jsonBody.Company = "Shephertz"
local App42CallBack = {}
App42API:initialize("API_KEY","SECRET_KEY")
local customCodeService = App42API:buildCustomCodeService()
customCodeService:runJavaCode(name, jsonBody,App42CallBack)
function App42CallBack:onSuccess(object)
	print(object)
end
function App42CallBack:onException(exception)
	if exception.getAppErrorCode() == 1902  then
		-- Handle here for Bad Request (Invalid JSON in request body.)
		elseif exception.getAppErrorCode() == 1900 then 
			-- Handle here for Bad Request (Jar File contains the invalid content or class usage that is not allowed for deployment)
			-- Example of it using System class or putting .sh/.dll file inside jar file
		elseif exception.getAppErrorCode() == 1401 then
			-- handle here for Client is not authorized  
		elseif exception.getAppErrorCode() == 1500 then
			-- handle here for Internal Server Error  
	end
end
const char* name = "DEPLOYED_CUSTOM_CODE_NAME";
App42Object *object = new App42Object();
object->setObject("Company", "Shephertz");
App42API::Initialize("API_KEY", "SECRET_KEY");
CustomCodeService *customCodeService = App42API::BuildCustomCodeService();
customCodeService->RunJavaCode(name, object,  app42callback(Sample_Class::onCustomCodeServiceRequestCompleted, this));
void Sample_Class::onCustomCodeServiceRequestCompleted(void *response)
{
    App42CustomCodeResponse *customCodeResponse = (App42CustomCodeResponse*)response;
    if(customCodeResponse->isSuccess)
    {
        //Handle success response here.
    }
    else
    {
        printf("\nerrordetails:%s",customCodeResponse->errorDetails.c_str());
        printf("\nerrorMessage:%s",customCodeResponse->errorMessage.c_str());
        printf("\nappErrorCode:%d",customCodeResponse->appErrorCode);
        printf("\nhttpErrorCode:%d",customCodeResponse->httpErrorCode);
        int appErrorCode = customCodeResponse->appErrorCode;
        if(appErrorCode == 1902) 
		{
			//Handle here for Bad Request (Invalid JSON in request body.)
		}
		else if(appErrorCode == 1900) 
		{
			//Handle here for Bad Request (Jar File contains the invalid content or class usage that is not allowed for deployment)
			//Example of it using System class or putting .sh/.dll file inside jar file
		}
		else if(appErrorCode == 1401)  
    	{  
        	// handle here for Client is not authorized  
    	}  
    	else if(appErrorCode == 1500)  
    	{  
        	// handle here for Internal Server Error  
    	}  
    }
}
  
String name = "DEPLOYED_CUSTOM_CODE_NAME";
JSONClass  jsonBody = new JSONClass ();
jsonBody.Add("Company", "Shephertz");
App42API.Initialize("API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.BuildCustomCodeService(); 
try 
{
	customCodeService.runJavaCode(name, jsonBody);
} 
catch (App42Exception ex) {
	int appErrorCode = ex.GetAppErrorCode();
	int httpErrorCode = ex.GetHttpErrorCode();
	if(ex.getAppErrorCode() == 1902) 
	{
		//Handle here for Bad Request (Invalid JSON in request body.)
	}
	else if(ex.getAppErrorCode() == 1900) 
	{
		//Handle here for Bad Request (Jar File contains the invalid content or class usage that is not allowed for deployment)
		//Example of it using System class or putting .sh/.dll file inside jar file
	}
	else if(ex.getAppErrorCode() == 1401)  
    {  
        // handle here for Client is not authorized  
    }  
    else if(ex.getAppErrorCode() == 1500)  
    {  
        // handle here for Internal Server Error  
    }  
    String jsonText = ex.GetMessage(); /* returns the Exception text in JSON format. (as shown below)*/ 
}	       
Not Available
Not Available
Not Available
var name:String = "DEPLOYED_CUSTOM_CODE_NAME";  
var jsonBody:Object = new Object;
jsonBody.Company = "Shephertz";
var api:ServiceAPI = new ServiceAPI("API_KEY","SECRET_KEY");
var customcodeService:CustomCodeService = api.buildCustomCodeService();
customcodeService.runJavaCode(name,jsonBody,new callback()); 
public class callback implements App42CallBack  
{
	public function onException(ex:App42Exception):void  
	{  
		var appErrorCode:int = ex.getAppErrorCode();
		var httpErrorCode:int = ex.getHttpErrorCode();
		if(ex.getAppErrorCode() == 1902) 
		{
			//Handle here for Bad Request (Invalid JSON in request body.)
		}
		else if(ex.getAppErrorCode() == 1900) 
		{
			//Handle here for Bad Request (Jar File contains the invalid content or class usage that is not allowed for deployment)
			//Example of it using System class or putting .sh/.dll file inside jar file
		}
		else if(ex.getAppErrorCode() == 1401)  
		{  
			// handle here for Client is not authorized  
		}  
		else if(ex.getAppErrorCode() == 1500)  
		{  
			// handle here for Internal Server Error  
		}  
	}  
	public function onSuccess(response:Object):void  
	{  
		trace("response is : " + response);
	}  
}  
Coming Soon
String name = "DEPLOYED_CUSTOM_CODE_NAME";
JSONObject jsonBody = new JSONObject();
jsonBody.put("Company", "Shephertz");
App42API.initialize("API_KEY","SECRET_KEY");
CustomCodeService customCodeService = App42API.buildCustomCodeService(); 
try 
{
	customCodeService.runJavaCode(name, jsonBody);
} 
catch (App42Exception ex) {
	int appErrorCode = ex.getAppErrorCode();
	int httpErrorCode = ex.getHttpErrorCode();
	if(ex.getAppErrorCode() == 1902) 
	{
		//Handle here for Bad Request (Invalid JSON in request body.)
	}
	else if(ex.getAppErrorCode() == 1900) 
	{
		//Handle here for Bad Request (Jar File contains the invalid content or class usage that is not allowed for deployment)
		//Example of it using System class or putting .sh/.dll file inside jar file
	}
	else if(ex.getAppErrorCode() == 1401)  
    {  
        // handle here for Client is not authorized  
    }  
    else if(ex.getAppErrorCode() == 1500)  
    {  
        // handle here for Internal Server Error  
    }  
    String jsonText = ex.getMessage(); /* returns the Exception text in JSON format. (as shown below)*/ 
}	
Error Codes

Functions in Custom API might throw exceptions with following HTTP and Application Error Codes (along with their descriptions):

1400 - BAD REQUEST - The Request parameters are invalid. 1401 - UNAUTHORIZED - Client is not authorized. 1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again. 1902 - BAD REQUEST - Invalid JSON in request body. 1903 - BAD REQUEST - Application Exception : Will include exception coming from your deployed code. For example, java.lang.NullPointerException. 1904 - BAD REQUEST - Application Exception : Request Execution Time Exceeded.