Delete a contact list unsuccessful - returning status: 200


#1

Hi there,

I am attempting to delete some test contact lists for an API I am writing.

The docs says a successful deletion will return a status 204, however I’m receiving 200.

I’m not entirely comfortable with HTTP requests so I know there is something wrong with my HTTP request code. The code is written in Node.js. I know there isn’t supposed to be any body information as the docs say all required information should be in the request URL.

First, here are my HTTP options

// set POST options var options = { hostname: 'api.hubapi.com', path: '/contacts/v1/lists/' + listID + '?hapikey=' + hubspotAPIKey, method: 'DELETE', headers: {} // I'm unsure what headers should be present }
I finally call the request function below …

    // set up request
    request = http.request(options, function(response) {
        console.log("Status: " + response.statusCode);
        response.setEncoding('utf8');

        // status codes from http response
        // 204 means successful delete
        if(response.statusCode === 204) {
            // update database
            console.log("List: ["+listID+"] has been deleted!");
        }

        // handle any events from request
        request.on('error', function(e) {
            deferred.reject("There was an error with the request - " + e);
        });

        request.on('close', function() {
            console.log("Connection has closed.");
        });

        request.on('finish', function() {
            console.log("Response was sent.");
        });

    }); // end of request callback
    request.end();

`

I’m unsure if I am missing any essential information in my HTTP request. Please let me know if you can see any obvious issues. If you need more information I am happy to provide it.

Thank you for your time.


#2

My apologies. It was not an issue with my HTTP request. It was an internal issue passing incorrect data around.

All is well!