Answered

Why won't my API call to create an export job work?

  • 8 September 2020
  • 21 replies
  • 125 views

I'm trying to use the api to create an export job. I'm using ver 2.2. Getting a response of "Requested resource is not available in current API version" when posting to https://api.intercom.io/export/messages/data?created_at_after=1596240000&created_at_before=1599586872

I confirmed the api key is working by doing a contact call and got the expected result. This is my first time using Intercom, so if someone can shed some light for me here it would be most appreciated.

icon

Best answer by Roy 8 September 2020, 23:38

View original

21 replies

Userlevel 1
Badge

Sorry for the previews reply, I just now tested it and seems there some problems with API. :/

Ah, ok. Any idea of timeframe to fix? Just so I can let my boss know.

Thanks for the reply, and sorry for the assumption with my other reply-for some reason I assumed you worked for the company, but as I thought about it I realize you’re probably another user trying to help me. Either way – thanks. 😊

Userlevel 1
Badge

@ken wny IRE​, I just found a solution here, it's working form Unstable version.

 

All you need to do is change the API version from the developer Hub.

intercom-unstable

 

 

 

Response:

jobintercom

 

 

 

Let me know if this works

Userlevel 1
Badge

@ken wny IRE​ , it definitely works from an Unstable version.

intercom-response

 

It means that there really some issues with the current API, hope the Intercom team reading this and fix it - @eric f11​ .

Great! I will try that tomorrow. Thank you very much!

Userlevel 1

Hey @roy s11​, thanks so much for flagging this with me! I'm following up with the team responsible for our API internally 👍

Userlevel 1

So, for now, it's expected behaviour that this is only available with the Unstable version. I've asked the team which manages our Developer Docs to update this to make it super clear that this is only available in the Unstable version - looks like this was forking off into the version 2.2 docs by accident!

Userlevel 1
Badge

Thank you @eric f11​  🙏

Eric, Thanks for clarifying this. Can you tell me how to access the unstable version via api call using the Intercom-Version header?

Well... I changed the version to unstable, and it seems that it really is unstable because now I am getting a 500 server error in response...  @eric f11 

Userlevel 1

Hey @ken wny IRE​, are you still getting 500 responses? We had a brief outage earlier.

Userlevel 1
Badge

@ken wny IRE​ , Intercom-Version: Unstable

Oh that explains it. No, now I'm getting a response saying that I need to include created_at_after and created_at_before fields, but I am sending those...

The body of my request has this json:

{

"created_at_after": 1596240000,

"created_at_before": 1599586872

}

Userlevel 1
Badge

Request:

{

 "created_at_after": 1527811200,

 "created_at_before": 1530316800

}

 

Response:

{

  "job_identifier": "*Hidden*",

  "status": "pending",

  "download_url": "",

  "download_expires_at": ""

}

 

It's working

Maybe this will help. Can you see if I am missing something here?

 

Here is my console info:

 

Accept: application/json

Content-Type: application/json

Authorization: Bearer my_token

Postman-Token: postman_token

Host: api.intercom.io

▶️

Request Body

{

"created_at_after": 1596240000,

"created_at_before": 1599586872

}

▶️

Response Headers

Date: Wed, 09 Sep 2020 19:11:39 GMT

Content-Type: application/json; charset=utf-8

Transfer-Encoding: chunked

Connection: keep-alive

Status: 400 Bad Request

Cache-Control: no-cache

X-RateLimit-Limit: 500

X-RateLimit-Reset: 1599678700

Strict-Transport-Security: max-age=31556952; includeSubDomains; preload

X-RateLimit-Remaining: 500

X-Intercom-Version: b763308b151c2e83df4dfc6654877de0c37445ec

Vary: Accept-Encoding

X-XSS-Protection: 1; mode=block

X-Request-Id: 0001rgseqie2v780v7eg

Intercom-Version: Unstable

X-Runtime: 0.057656

X-Frame-Options: SAMEORIGIN

X-Content-Type-Options: nosniff

 

▶️

Response Body

{"type":"error.list","request_id":null,"errors":[{"code":"bad_request","message":"'created_at_after' is a required parameter"},{"code":"bad_request","message":"'created_at_before' is a required parameter"}]}

 

Userlevel 1
Badge

@ken wny IRE​, You should use https://api.intercom.io/export/messages/data/p>

I am. It's responding with

{

"type": "error.list",

"request_id": null,

"errors": [

{

"code": "bad_request",

"message": "'created_at_after' is a required parameter"

},

{

"code": "bad_request",

"message": "'created_at_before' is a required parameter"

}

]

}

Userlevel 1
Badge

@ken wny IRE​ , Please take a look to Postman configuration.

 

postman-1

postman-2

postman-3

curl-code

Thank you for posting those screen shots. I found the problem. I was not sending Content-Length, and apparently, that is what was missing. So now it works in Postman, but I still have to figure out how to send that header in my php code using Guzzle, because that is still not working. Apparently the server does not like it when that header is missing....

 

Edit: The reason my code was not working right was because I wasn't sending a timestamp, but a string. I didn't have to send the Content-Length header in my code, so my conclusion is that Postman requires that header -without it, it must not send any content, which would explain why the server was asking for those variables, because postman never actually sent them!

 

 

Thank you for all your help! I really appreciate it!

Reply