Coder Social home page Coder Social logo

Comments (9)

franz-josef-kaiser avatar franz-josef-kaiser commented on June 26, 2024 5

Ok, this has been a big time misunderstanding: The fact that links.error is present, does not mean that an error occurred. Instead, this is just a pointer to any possible errors. The job gets queued on Intercom side and has the state of running – for hours or even days. In case an error happened, the url will have the full error available. One just has to perform another request to fetch the list of errors, again with an Accept header of application/json like the rest of the API. The endpoint is not meant to be accessible via a browser. One can try Postman or similar applications to retrieve that data. Or poll the Intercom servers for the state of a job over a longer period and in case it failed, fetch the result and save it somewhere for inspection.

from intercom-node.

beastawakens avatar beastawakens commented on June 26, 2024 1

@franz-josef-kaiser This appears to be that you're receiving the correct job model response, but when you try to access the error URL, you are not passing the 'Accept' header, so it is returning that response. Try accessing the error URL and passing the correct 'Accept' header with it. Does that help?

from intercom-node.

coopernewby avatar coopernewby commented on June 26, 2024 1

Yes! Got it. I ran this and got much more information on the job about errors or if the bulg job was done curl -u 'app_id':'app_api_key' -H 'Content-Type: application/json' -H 'Accept: application/json' https://api.intercom.io/jobs/job_8de063a0_43cb_11e6_a749_11589fe21ce7

from intercom-node.

franz-josef-kaiser avatar franz-josef-kaiser commented on June 26, 2024

Update: I tried to switch away from your client and use the widely spread request package. The result is the same:

    return request.post( {
        uri : 'https://api.intercom.io/bulk/users',
        'auth': {
            'user' : process.env.INTERCOM_APP_ID,
            'pass' : process.env.INTERCOM_APP_ID_KEY,
            'sendImmediately' : false
        },
        headers : {
            'Accept'       : 'application/json',
            'Content-Type' : 'application/json'
        },
        body : { items : members },
        json : true,
        transform : function( body, response, resolveWithFullResponse ) {
            console.info( '[intercom] [INFO] [Setup: transform]',
                JSON.stringify( body )
            );
            return body;
        }
    } )
        .then( function( response ) {
            console.info( '[intercom] [INFO] [Setup: response]', response );
        } )

The transform closure log gives the following output:

[intercom] [INFO] [Setup: transform]
{
    "app_id": "xxxxx",
    "id": "job_xxx",
    "created_at": 1464183095,
    "completed_at": null,
    "closing_at": 1464183995,
    "updated_at": 1464183095,
    "name": "api_bulk_job",
    "state": "running",
    "links": {
        "error": "https://api.intercom.io/jobs/job_xxx/error",
        "self": "https://api.intercom.io/jobs/job_xxx"
    }
}

The actual response is the following:

[intercom] [INFO] [Setup: response] 
{
    app_id       : 'xxxxx',
    id           : 'job_xxx',
    created_at   : 1464183095,
    completed_at : null,
    closing_at   : 1464183995,
    updated_at   : 1464183095,
    name         : 'api_bulk_job',
    state        : 'running',
    links        :  {
        error : 'https://api.intercom.io/jobs/job_xxx/error',
        self  : 'https://api.intercom.io/jobs/job_xxx'
    }
}

Where the links.error is above posted error in logs with media_type_not_acceptable.

from intercom-node.

franz-josef-kaiser avatar franz-josef-kaiser commented on June 26, 2024

@edkellena As you can see from above plain request using the npm request package, I set the correct Accept header…

from intercom-node.

coopernewby avatar coopernewby commented on June 26, 2024

I believe I am having the same issue, using the node intercom client
headers:
{ 'Content-Type': 'application/json',
Accept: 'application/json',
'User-Agent': 'intercom-node-client/2.0.0',
authorization: 'Basic bmkxbmN6ZG46MmQ1YmQ3MzM5NjkyOWI5YWFlNzUxZjJlOGI3NDc5MGYwOWU1ZWVhNA==',
'content-length': 3057 },

from intercom-node.

franz-josef-kaiser avatar franz-josef-kaiser commented on June 26, 2024

@coopernewby Have you read my last comment? Job queue and such?

P.s.: Can you please use code formatting? Makes it much easier to read.

from intercom-node.

coopernewby avatar coopernewby commented on June 26, 2024

Yes sorry about the formatting. I just don't understand how long the bulk jobs seem to run for or how to fix the 'media_type_not_acceptable' error. This is what I am passing in:
bulkUsers.push({ create: { email: output[j][0], user_id: output[j][4], type: output[j][9], name: output[j][2], companies: [{ id: output[j][6] }] } })

from intercom-node.

franz-josef-kaiser avatar franz-josef-kaiser commented on June 26, 2024

Are you looking at the request in a browser? Use something like the Postman app instead.

from intercom-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.