APIs & Integrations

BWATKINS2000
Member

Should 404 also return Response content or error message?

Hello,

We've been having issues with the API on our production server since approx 2/25. It worked fine prior to that. Now...
It does not matter what we attempt to do (add/ update company, contact, deal). When the code is executed from website running on production server, always get back 404 with nothing in either Response.Content or Response.ErrorMessage. Should either of these fields have data if it's a legit 404 and it authenticated okay?

Same exact code and test scenarios run from local dev computer (localhost) with same database connection, returns 200 for exact same calls against exact same records.

I added logging to better track what's happening but all calls to API are returning the 404 and no helpful info. Wondering if it should at least be returning the the portalId in response content if successful connect. If not authenticating, would expect a different code or error message.

I'm perplexed. Any assistance would be appreciated.

C# Code...

// API Endpoint Paramaters
        private static string ApiEndpoint = "https://api.hubapi.com/";
        private static string ApiUserAgent = "FMP Hubspot API Connector v1.0";


        private static JObject CallAPI(Method oMethod, string oUrl, string oQueryString, JObject oContent)
        {
             ApiKey = ApiKeyLIVE;

            string lRequestContent = "";

            if (String.IsNullOrEmpty(ApiKey))
            {
                throw new Exception("Hubspot API Key is not defined");
            }

            string url = string.Format("{0}{1}", ApiEndpoint, oUrl);

            RestClient client = new RestClient(ApiEndpoint);
            RestRequest request = new RestRequest("{url}", oMethod);
            request.AddUrlSegment("url", oUrl);
            request.AddQueryParameter("hapikey", ApiKey);

            request.RequestFormat = DataFormat.Json;
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("User-Agent", ApiUserAgent);
            if (oContent != null)
            {
// NOTE: tried both way - specifying Content-Type param and not in the AddParameter call
                //request.AddParameter("application/json; charset=utf-8", oContent.ToString(Formatting.None), ParameterType.RequestBody);
                request.AddParameter("application/json; charset=utf-8", oContent.ToString(Formatting.None), "application/json", ParameterType.RequestBody);

                lRequestContent = oContent.ToString(Formatting.None);
            }

            IRestResponse response = client.Execute(request);
            // @TODO - Add check to make sure our response is an object and not an array (wrap in {"result":response.Content} if not)
            setStatusCode(response);
            JObject result = String.IsNullOrEmpty(response.Content) ? new JObject() : JObject.Parse(response.Content);

            LogIt(ApiMode, ApiKey, ApiUserAgent, oMethod.ToString(), url, oQueryString, (int)response.StatusCode, response.Content.ToString(), response.ErrorMessage, lRequestContent);

            return result;
        }

Here are a couple examples of what's being sent. EVERY time returns 404 with no other info.

GET https://api.hubapi.com/contacts/v1/contact/email/Name@server.com/profile
POST https://api.hubapi.com/contacts/v1/contact

0 Upvotes
23 Replies 23
RMelr33
Member

Should 404 also return Response content or error message?

I actually have this issue. I'm the usage of a Mac and seeking to tune through BCCing my hubspot email cope with. Is there a way to do that? I actually have a Mac and handiest have Officee 365, not the model you need for the upload new file like this-in. Can I song just with the hubspot e mail?

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Should 404 also return Response content or error message?

Hi @BWATKINS2000,

Thanks a ton for your patience here, I know this has been a long road to resolution. This appears to be a bug in the code as written; the issue is that when a Url segment is serialized in the code below, the value provided is UrlEscaped

RestRequest request = new RestRequest("{url}", oMethod);
request.AddUrlSegment("url", oUrl);

Which turns

https://api.hubapi.com/contacts/v1/contact/email/Name@server.com/profile

into

https://api.hubapi.com/contacts%2Fv1%2Fcontact%2Femail%2FName%40server.com%2F 

My team and I were able to reproduce the 404 locally when running the example code you gave. Can you try replacing the lines of code above with:

RestRequest request = new RestRequest(oUrl, oMethod);
0 Upvotes
BWATKINS2000
Member

Should 404 also return Response content or error message?

I will give it a shot. Thanks!

0 Upvotes
BWATKINS2000
Member

Should 404 also return Response content or error message?

Hi Derek,

I'm happy to report that the suggestion you provided solved the problem. Still think it's crazy that it was an issue only from some websites and not others but thrilled that it is now resolved. Thanks for your help.

Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Should 404 also return Response content or error message?

Hi @BWATKINS2000,

Thanks for your patience here; this fell off my radar since it'd been a while between updates. I'm going to take this to my team to do some deeper digging; this seems to be occurring a layer deeper than I thought, so I'll need to dig in with them. If you have any other recent examples of this that'd be extremely helpful, but otherwise I'll post updates in this topic as I have them.

0 Upvotes
BWATKINS2000
Member

Should 404 also return Response content or error message?

I can provide all kinds of examples. Let me know specifics that are most helpful to you. I'm logging all info on request and response side.

0 Upvotes
BWATKINS2000
Member

Should 404 also return Response content or error message?

Here is an example of a response that returns with status 404 but nothing in the Error Message. Nor did it raise any errors. The PUT request in this case looks just like one that works when I run the same code from my local dev environment connected to the production server, so I don't think it is formatting issue or else it would have more consistent results rather than works from one website but not another.

Response Headers:

Connection=keep-alive
Access-Control-Allow-Credentials=false
X-Trace=2B230815D26D5F6F362E34AA3325307FFB16903998000000000000000000
Strict-Transport-Security=max-age=31536000; includeSubDomains; preload
Expect-CT=max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
CF-RAY=43cf822fffbc56ff-IAD
Content-Length=0
Date=Thu, 19 Jul 2018 19:14:00 GMT
Set-Cookie=__cfduid=abc123; expires=Fri, 19-Jul-19 19:14:00 GMT; path=/; domain=.hubapi.com; HttpOnly
Server=cloudflare

I'm hoping that you can look at this from the cloudflare side to see if there's a way to tell if cloudflare is failing to pass it on for some reason. Or if there is an error of some sort that cloudflare is not passing back.

Appreciate your help in getting this figured out.

Thanks,
Belinda

0 Upvotes
BWATKINS2000
Member

Should 404 also return Response content or error message?

Hi @Derek_Gervais,

Hope you are doing well. Was hoping you could give a little more help / guidance on the issue we are experiencing. Seems our messages make it to cloudflare but are returning 404 with empty response / error message / etc. I can pull more current example if you can take a look. If I should be reaching out to someone else, please advise.

Thanks!

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Should 404 also return Response content or error message?

Hi @BWATKINS2000,

We support TLS 1.0/1.1/1.2, but not 1.3, and we don't have any explicit requirements on .NET but I would imagine newer versions would be better supported. I'm not seeing any of these errors in out error logging, but we don't store logs for request that don't make it past the TCP handshake stage, which leads me to believe these aren't showing up in the logs for that reason.

I'm thinking this might be an issue with the root CA or the supported ciphers of your production server. Can you make sure that your server and root CA is up to date? If you're updating based on the Mozilla Root CA Store you shouldn't have issues; also here are the ciphers we use:
https://www.ssllabs.com/ssltest/analyze.html?d=api.hubapi.com&s=2400%3Acb00%3A2048%3A1%3A0%3A0%3A681...

0 Upvotes
BWATKINS2000
Member

Should 404 also return Response content or error message?

Hi @Derek_Gervais,

I'm now logging Response Headers among many other fields. We are getting a response Header value from cloudflare. Among other things in there is "Content-Length=0" which corresponds to empty Response Content. But response status code = 404 and no error message.

Are you able to examine traffic there to see if you can detect anything? If so, I can provide more info.

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Should 404 also return Response content or error message?

Hi @BWATKINS2000,

I'm not seeing any of these 404s, but the logs only go back 7 days so I can't see anything from 5/29. Some next steps:

  1. Are you using a hapieky or OAuth for authentication? If you're using OAuth, can you post your appId?
  2. Is there a way for you to run a test of this code that can quickly reproduce these errors? I know turnaround here has been fairly long given the current forum volume, but if you can run a test and create a number of these errors I should be able to check our logs. It's suspicious that I'm not seeing any trace of these errors, but I want to completely eliminate the possibility that it's because the logs only go back 7 days.
0 Upvotes
BWATKINS2000
Member

Should 404 also return Response content or error message?

We are using ApiKey.

If you look at today - there are already 135+ transaction attempts. Only 2 were successful and those were a test from running the web app from my local DEV computer connected to the LIVE database.

I think there has to be something different about the environment on our LIVE web server vs my dev environment but I'm not sure what to look for. What minimum version of TLS do you guys require? Any minimum version of .NET at play?

0 Upvotes
BWATKINS2000
Member

Should 404 also return Response content or error message?

Hi. Yes, we are still having issues with this. I have been manually doing a sync by connecting my local dev environment to the live DB and then can do a push -- calling same exact code -- and get the deals, contacts, etc to push. I am noticing that occasionally a transaction here or there will go thru via the live site.

I did a manual push 5/29 around 10 am. Will do another one shortly. If you look at dates from 5/29 post 10 am = 6/1, you will see lots of 404's -- At least I do!

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Should 404 also return Response content or error message?

Hi @BWATKINS2000,

Thanks for your patience here. So looking at some high-level request traffic for your portal (Hub ID 720952), I'm not seeing a particularly large percentage of errors. I'm only seeing ~22 404 errors over the past few days, and they all appear to be coming from the 'Get contact by email' or 'Update contact by vid' endpoints. Are you still running into issues with requests coming from your production server?

0 Upvotes
BWATKINS2000
Member

Should 404 also return Response content or error message?

Here's a bit more narrow date range...
Between 5/30/2018 and 6/1/2018 11:59 PM
1247 transactions attempts
15 successful Deal updates (PUT) - status 200
1232 failed - 404 status code and nothing in the ResponseContent field

Are you able to confirm if those transactions are even making it to the Hubspot server ?

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Should 404 also return Response content or error message?

Hi @BWATKINS2000,

Can you give me your Hub ID?

0 Upvotes
BWATKINS2000
Member

Should 404 also return Response content or error message?

I typo-ed the Hub ID in the last post. Wanted to resubmit it. It is actually 720952

0 Upvotes
BWATKINS2000
Member

Should 404 also return Response content or error message?

Hi @Derek_Gervais,

In addition to providing Hub ID 72092, wanted to mention that the recently added / updated records were done so most recently on 5/6 outside the normal production server. I was using my work around -- using my local dev environment as the website but connected to the production database.

Appreciate any help you can provide.

0 Upvotes
BWATKINS2000
Member

Should 404 also return Response content or error message?

The hub Id for the account having issues is... 720952

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Should 404 also return Response content or error message?

Hi @BWATKINS2000,

Is it possible that the Content-type header is being excluded? It has to be set to application/json, and sometimes weird things happen when people leave that out. Also, if you use OAuth2 for authentication you'll have access to API Call Logging in your developer portal.

0 Upvotes