How to set dbname when using custom code. App42API is not allowed.

0 votes


We need to use userService in custom code and we need to fetch additional data for user and that requires dbname to be set as :


But we cannot deploy this custom code, below is the error:

"message":"Bad Request","details":"Class can not be used in custom code deployment c : in source com.shephertz.app42.paas.customcode.commons.App42Utilities"}}

Please help.

asked Jan 19, 2016 in Java by jitesh.h.lalwani (20 points)

1 Answer

0 votes
Best answer

Hi Jitesh,


Please find below code snippet to fetch user meta information inside custom code and let me know if it helps:

String userName = "UserName";
ServiceAPI serviceAPI = new ServiceAPI("API_KEY", "SECRET_KEY");
UserService userService = serviceAPI.buildUserService(); 
HashMap<String, String> otherMetaHeaders = new HashMap<String, String>();
JSONObject json = new JSONObject();
json.put("dbName", "Your_DBName");
json.put("collectionName", "Your_CollectionName");
otherMetaHeaders.put("dbCredentials", json.toString());
Query query ="Key", "Value", Operator.EQUALS); 
otherMetaHeaders.put("metaQuery", query.getStr());
User user = userService.getUser(userName); 
System.out.println("userName is " + user.getUserName());
for(int i=0;i<user.getJsonDocList().size();i++)
System.out.println("updated at = "+ user.getJsonDocList().get(i).getUpdatedAt());
System.out.println("created at = "+ user.getJsonDocList().get(i).getCreatedAt());
System.out.println("doc id is = "+ user.getJsonDocList().get(i).getDocId());
System.out.println("json doc  is = "+ user.getJsonDocList().get(i).getJsonDoc()); 


Himanshu sharma
answered Jan 20, 2016 by hs00105 (2,005 points)
selected Mar 4, 2016 by jitesh.h.lalwani
Thank you. That worked!
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