1

I would try to create an API Rest client for a code that I have in a GWT project. In order to arrive to the server and obtain a response I need to attach some custom headers in my request.

I saw, there were some bugs some years ago when write headers in the request. Actually, I have this code, and I don't know exactly where and when put my custom header in the request.

    final Map<String, String> headers = new HashMap<String, String>();
    headers.put("X-USER", "super_admin_key");           
    Resource resource = new Resource("http://localhost:9998/api/v1/", headers);

    ServicesAPI service = GWT.create(ServicesAPI.class);
    ((RestServiceProxy)service).setResource(resource);      

    REST.withCallback(new MethodCallback<String>(){

        @Override
        public void onFailure(org.fusesource.restygwt.client.Method method, Throwable exception) {
            domainsCombo.addItem("ERROR");              
        }

        @Override
        public void onSuccess(org.fusesource.restygwt.client.Method method, String response) {
            domainsCombo.addItem("ok");             
        }           

    }).call(service).getServices();

Add headers to the resource object creation is one of the options, but it doesn't work. Any sugestion?

Thanks.

DavidR.
  • 93
  • 6
  • Can you edit your question and give what resty is putting in your Request headers? (Use dev Tool in your browser to check it) – Pintouch Oct 24 '14 at 06:29

0 Answers0