Reputation: 1253
i've been given the task to send a POST message to the server giving it a JSON encoded message. The server would then send back a responce in a custom HTTP header field “X-SubmissionResponse”
so far i can successfully connect to the server (i know this because i get the responce code 202)
but i am having a lot of difficulty in getting the information from the responce, below is the code that i am currently using.
Error content not available
This code ends up returning null, Can anyone see what i am missing here?
This is the code above the if statement ^
Error content not available
Upvotes: 0
Views: 506
Reputation: 9274
Header name = response.getFirstHeader("X-SubmissionResponse");
String whatsInhere = "";
if (name != null)
whatsInhere = name.getValue();
Try using the correct methods of the Class Header. See http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/Header.html
Upvotes: 1
Reputation: 39403
HttpHead head = new HttpHead();
creates a new HEAD request, empty, that does not do anything in itself.
You want the header from the response to your request. Get it by simply:
Header name = response.getFirstHeader("X-SubmissionResponse");
Upvotes: 1