I’m in the process of testing the Single Send API and trying to build some logic in my application based on the sendResult field sent back to me in the response. I’m able to send an email successfully and I do get the “SENT” result back.
But when I change the emailId field passed in the JSON to one that is not set up for Singe Send (doing this purposely to test different results), my call to get the response is failing with a “System.Net.WebException: The remote server returned an error: (400) Bad Request.”
I was expecting to successfully get back a response of “MISSING_CONTENT” as described in the documentation. I’m not sure if this is the intended behavior or if I’m doing something wrong here.
I tried testing my call through an application called Postman and I can see that HubSpot is returning the JSON response I was expecting when a web exception is thrown.
I am making my call through Dynamics AX in X++. Not sure if you have any customers doing the same thing but once the request.GetResponse() throws the exception (it throws a CLR exception), there’s no way for me to get the accompanying response body. Or at least I have not been able to find a solution after searching different Dynamics AX forums for days.
But the Postman app did help me verify that a response was sent along with the web exception.
@aga The email id it self wouldn’t be considered Content for Us. Also you did supply an ID just an incorrect one. This is working how it is designed and it sounds like you are testing correctly!
I’m still a little confused. In what scenario then would I receive the response described below from the documentation page?
“MISSING_CONTENT — The emailId is invalid, or the emailId is an email that is not set up for Single Send.”
I’ve also tried taking out the @ symbol from the recipient address and I’m getting the same Bad Request error instead of the response below:
“INVALID_TO_ADDRESS — The recipient address is invalid.”
This is the JSON I am sending which gives me a “SENT” response. I’m changing just the “emailId” field for testing purposes and sending the rest of the JSON as is.
@aga Can you post the full return as well, also the call?(please x out your hapikey/token) I’d like to be able to see it. There does seem to be a discrepancy in our documentation and what you are experiencing .
Full return:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
— End of inner exception stack trace —
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at ClrBridgeImpl.InvokeClrInstanceMethod(ClrBridgeImpl* , ObjectWrapper* objectWrapper, Char* pszMethodName, Int32 argsLength, ObjectWrapper** arguments, Boolean* argsAreByRef, Boolean* isException)