I am using java sdk for bulk activities. How I can get the http response status code from response returned or from exception thrown.
I could not find a way for it. Can some one help me in this?
ConstantContact constantContact = new ConstantContact(key, token);
ExportContactsRequest bulkReq = new ExportContactsRequest();
// set bulkReq details
ContactsResponse res = constantContact.exportBulkContacts(bulkReq);
catch (ConstantContactServiceException e)
You can get this data using the getErrorInfo() method of the ConstantContactServiceException class. It will return List<CUrlRequestError>. Each CUrlRequestError object will have a key/value pair, and one of those pairs will contain the status code for your request. In addition, this information will contain the error message (if any) that is returned by the API.
I have tried this thing to get status code like (3XX, 4XX or 5XX) but could not get.
It looks like there are some mappings created for these codes and some error key/value is returned based on that.
Is there any documentation available which can tell me these details.
After working on this a bit further, I was able to find an error where the status code information was being omitted from the response info when there was a JSON body present in the response. Given how this is happening, we are looking into how we can fix the problem properly and make the library most usable.
However, as I know you are dealing with the problem right now, I have created a "quick and dirty" fix that will enable this functionality in the immediate term while we are looking for a better solution. To make use of this, you will want to update src/main/java/com/constantcontact/util/http/HttpProcessor.java from this Gist: https://gist.github.com/egaiter/59228f03bcc2e98d9fc8
Once you've done this, it will force all errored requests that have a JSON body to also include a status_code key/value pair in the request info.
If you have any further questions, please let me know!