0

I am using this code to update a task through a RequestForUpdate in an Android Native App The onSuccess method is executed but It seems the field is not updated.

Why?

            Map<String,Object> fields = new HashMap<String,Object>();
            String id = "00Tw000001wvUCVEA2";
            fields.put("Subject", "A Subject" );
            try {
                    RestRequest.getRequestForUpdate("30.0", "Task", id, fields);
                    TaskGridFragment.this.client.sendAsync(request, new AsyncRequestCallback() {
                                @Override
                                public void onSuccess(RestRequest request,
                                        RestResponse response) {
                                        System.out.println("UPDATE RESP "+response);
                                }

                                @Override
                                public void onError(Exception exception) {
                                    // TODO Auto-generated method stub
                                    System.out.println("UPDATE FAIL ");
                                    exception.printStackTrace();
                                }
                            });
                        } catch (UnsupportedEncodingException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }

1 Answer 1

2

Check the actual response you're getting. Depending on the API you might find that success is being called because you're getting an HTTP 200 code (i.e. ok) but it could be the content of that response actually contains an error.

10
  • The status code is 200 how can i get the content you mentioned ? Sep 24, 2014 at 10:25
  • it seems it always returns 200 regardless of the Key in the fields map! How can I use it properly? Sep 24, 2014 at 10:40
  • What are you seeing in the debug output from this line: System.out.println("UPDATE RESP "+response); That should tell you what you need to do. Alternatively try and update the same field with the same user via the browser to see what might be stopping you.
    – Matt Lacey
    Sep 24, 2014 at 10:42
  • I get the JSON of all the existing tasks (11) included the one I tried to update Sep 24, 2014 at 10:44
  • That doesn't sound right... I'd expect you to only see the one you're updating. You're definitely checking the output of the right callback and not the callback for a different request?
    – Matt Lacey
    Sep 24, 2014 at 10:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .