Custom code acces via url

0 votes

Greetings, so i am using the custom code service and however i am having problems i need light on this, and there no information addressing this directly.. i would like to access my custom code via the url and i get error, this is my code please help

 

    try{
                    JSONObject json = new JSONObject();
                    try {
                        json.put(Dictionary.JSON_KEY_OPERATION,
                                Dictionary.OPERATION_AUTHENTICATE_USER_TOKEN);
                    } catch (JSONException e) {}
                    try {
                        json.put(Dictionary.JSON_KEY_DATA_INPUT_EMAIL, MainActivity.txtD.email);
                    } catch (JSONException e) {}
                    try {
                        json.put(Dictionary.JSON_KEY_DATA_INPUT_NUMBER, MainActivity.txtD.number);
                    } catch (JSONException e) {}
                    try {
                        json.put(Dictionary.JSON_KEY_DATA_INPUT_PIN_CODE, ed.getText().toString());
                    } catch (JSONException e) {}
                    
                    HttpURLConnection httpcon = (HttpURLConnection)
                            ((new URL (Dictionary.URL).openConnection()));
                    httpcon.setDoOutput(true);
                    httpcon.setRequestProperty("Content-Type", "application/json");
                    httpcon.setRequestProperty("Accept", "application/json");
                    httpcon.setRequestMethod("POST");
                    httpcon.connect();
                    
                    OutputStream os = httpcon.getOutputStream();
                    BufferedWriter writer = new BufferedWriter(
                            new OutputStreamWriter(os, "UTF-8"));
                    writer.write(json.toString());
                    writer.close();
                    os.close();
                }catch(Exception d){
                    d.printStackTrace();
                }

 

 

and the error code i get is 400 - bad request , is this the right way to go, can i have a demo that uses my way

 

asked Aug 20, 2015 in App42 Cloud API-BaaS by rumorsapp (14 points)
Hello,

Could you please let us know why you need to access it through url? You can directly use SDK method to call your custom code.

Please let us know your complete use case, it will help us to provide better support from our end.

Thanks in advance.

Regards,
Himanshu Sharma
well thank you Sir Himanshu Sharma for your comment, well for starters you awesome platform has that feature, accessing it through a link, so my quest was why not since

1: it helps reduce your .apk size because of my additional libraries i will have
2: its not that much of a tedious task so i would love to not add much to it, it terms of a lot of stuff for a simple stuff, you get me sir?
3: and at the end of the day for security

also but why do you guys have it actually?  i would love to know its primary goal, so i do not actually misuse it or anything.

Thanks
rumorsapp -Terah
Hello Rumorsapp,

Thanks for sharing your use case with us. We can do one thing, we can create one demo sample which will complete your use case, we will provide you by tomorrow.

Let me know if it helps.

Regards,
Himanshu Sharma

1 Answer

+1 vote
Hello Rumor,

 

Internal server error comes when client is not able to send the exact paramter which is required in the method call. Please can you share the code snipped in which you are working on. It will help me to tell what is the exact reason behind it.

Regards,

Himanshu Sharma
answered Aug 23, 2015 by hs00105 (2,005 points)
i have solved it thanks for your assistance sir
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
...