HTTP 404 Object_Not_Found

Hi there,

We’ve created a private App. Did the scope. Got the token. Send the following request:

//*********

var client = new RestClient(“https://api.hubapi.com/crm/v3/objects/contacts”);

var request = new RestRequest(Method.GET);
request.AddHeader(“accept”, “application/json”);
request.AddHeader(“authorization”, $“Bearer {token}”)

IRestResponse response = client.Execute(request);

//*****

Token is correct

We have over 3000 contacts

I have been getting HTTP 404 Object_Not_Found

Any help will be appreciated

Hi, @Kabaja :waving_hand: Welcome to the community. I have questions and not answers. And let’s see if we can get there anyway.

Questions:

  • You are using theGET /crm/v3/objects/contacts​

    on this page, correct? — CRM API > Contacts > List

  • And you are using the C# example from the documentation? Is that correct?

I created a Private App with only the needed scope and tried from the documentation example:
Request

var client = new RestClient("https://api.hubapi.com/crm/v3/objects/contacts?limit=100&archived=false");
var request = new RestRequest(Method.GET);
request.AddHeader("accept", "application/json");
request.AddHeader("authorization", "Bearer YOUR_ACCESS_TOKEN");
IRestResponse response = client.Execute(request);

Response

{
 "results": [
 {
 "id": "1",
 "properties": {
 "createdate": "2022-06-29T17:59:00.693Z",
 "email": "emailmaria@hubspot.com",
 "firstname": "Maria",
 "hs_object_id": "1",
 "lastmodifieddate": "2022-08-11T23:25:03.952Z",
 "lastname": "Johnson (Sample Contact)"
 },
 "createdAt": "2022-06-29T17:59:00.693Z",
 "updatedAt": "2022-08-11T23:25:03.952Z",
 "archived": false
 },
 {
 "id": "51",
 "properties": {
 "createdate": "2022-06-29T17:59:01.172Z",
 "email": "bh@hubspot.com",
 "firstname": "Brian",
 "hs_object_id": "51",
 "lastmodifieddate": "2022-08-02T17:50:32.754Z",
 "lastname": "Halligan (Sample Contact)"
 },
 "createdAt": "2022-06-29T17:59:01.172Z",
 "updatedAt": "2022-08-02T17:50:32.754Z",
 "archived": false
 },
 {
 "id": "101",
 "properties": {
 "createdate": "2022-06-30T04:07:35.653Z",
 "email": "jaycee@example.com",
 "firstname": null,
 "hs_object_id": "101",
 "lastmodifieddate": "2022-08-02T17:50:32.092Z",
 "lastname": null
 },
 "createdAt": "2022-06-30T04:07:35.653Z",
 "updatedAt": "2022-08-02T17:50:32.092Z",
 "archived": false
 },
 {
 "id": "201",
 "properties": {
 "createdate": "2022-06-30T05:20:31.927Z",
 "email": "jaycee222@example.com",
 "firstname": null,
 "hs_object_id": "201",
 "lastmodifieddate": "2022-08-02T17:50:33.777Z",
 "lastname": null
 },
 "createdAt": "2022-06-30T05:20:31.927Z",
 "updatedAt": "2022-08-02T17:50:33.777Z",
 "archived": false
 }
]
}

Can you share the full response body? Hey, @klloyd__1 @DanielSanchez is there a better way to think about this one?

Thank you for taking a look! — Jaycee

Hi Jaycee,

Thank you for the follow-up.

The answer to All questions: Correct.

We’ve rotated a token couple of times. Use the same C# sample request.

For the above code sample, now we get 400. Here the response from the private App logs:

{
“User-Agent”: [
“RestSharp/108.0.2.0”
],
“CDN-Loop”: [
“cloudflare; subreqs=1”
],
“Accept-Encoding”: [
“gzip”
],
“CF-Connecting-IP”: [
“2607:fea8:4f25:da00:4d77:5bed:952e:2a10”
],
“True-Client-IP”: [
“2607:fea8:4f25:da00:4d77:5bed:952e:2a10”
],
“X-HubSpot-Trace”: [
“0a0fa450d9fda22ef8ffa19c12309d48”
],
“Authorization”: [
“Bearer pat-na******”
],
“X-HubSpot-Correlation-Id”: [
“024f982d-e4f9-4a9b-8e83-61f4a0749b1d”
],
“X-HS-Internal-Request”: [
“1”
],
“X-Real-IP”: [
“2607:fea8:4f25:da00:4d77:5bed:952e:2a10”
],
“cf-worker”: [
“hubapi.com”
],
“CF-Ray”: [
“7489eb3637f6a1d8-IAD”
],
“Accept”: [
“application/json”
],
“CF-IPCountry”: [
“CA”
],
“X-Forwarded-Proto”: [
“https”
],
“Connection”: [
“close”
],
“X-Request-Start”: [
“1662831312.375”
],
“X-HS-Internal-User-Request”: [
“0”
],
“Host”: [
“api.hubapi.com”
],
“CF-Visitor”: [
“{\“scheme\”:\“https\”}”
],
“X-HS-User-Request”: [
“0”
],
“CF-EW-Via”: [
“15”
],
“X-Forwarded-Port”: [
“443”
],
“X-Amzn-Trace-Id”: [
“Root=1-631ccad0-35b8136a7e6250330954ce7b”
],
“X-Forwarded-For”: [
“2607:fea8:4f25:da00:4d77:5bed:952e:2a10, 172.70.42.143, 2607:fea8:4f25:da00:4d77:5bed:952e:2a10”
],
“X-Scheme”: [
“https”
]
}

**************From the debugger:

System.Collections.Generic.List`1[RestSharp.HeaderParameter] {“status”:“error”,“message”:“Unable to infer object type from: 0”,“correlationId”:“024f982d-e4f9-4a9b-8e83-61f4a0749b1d”} System.Net.Http.HttpRequestException: Request failed with status code BadRequest RestSharp.RestRequest

URI:"https://api.hubapi.com/crm/v3/objects/0"

Thank you. This issue has been resolved. FYI couple of issues

1

RestClient(“https://api.hubapi.com/crm/v3/objects/companies//associations/?limit=500”);

will always return 400 “bad requests” I believe the server max is limit=100

So any request over 100 with any object will return 400 Bad requests.

Issue #2

Not sure with RestSharp in many cases was returning a bad request. " This is documented well on the web"