Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete multiple builds not working #37

Open
SassNinja opened this issue Aug 29, 2019 · 1 comment
Open

delete multiple builds not working #37

SassNinja opened this issue Aug 29, 2019 · 1 comment

Comments

@SassNinja
Copy link

When I use the curl example from the docs it works without any problem

curl -u "xxxx:xxxx" -X DELETE "https://api.browserstack.com/automate/builds?buildId=xxxx"

but when I try to do the same with node I always get a 302 redirect error

const request = require('request')

request({
	url: 'https://api.browserstack.com/automate/builds?buildId=xxxx',
	method: 'DELETE',
	auth: {
		user: 'xxxx',
		pass: 'xxxx'
	}
}, (err, res, body) => {
	if (res.statusCode === 201) {
		console.log('success')
	} else {
		console.log('error: ' + res.statusCode)
		console.log(body)
	}
})

the code above logs

error: 302
<html><body>You are being <a href="https://api.browserstack.com/users/sign_in">redirected</a>.</body></html>

When I modify the code to e.g. change the status of a session it works.

request({
	url: `https://api.browserstack.com/automate/sessions/xxxx.json`,
	method: 'PUT',
	headers: {
		'Content-Type': 'application/json'
	},
	body: `{"status":"error"}`,
	auth: {
		user: 'xxxx',
		pass: 'xxxx'
	}
})

Is there any internal difference I need to consider when trying to modify multiple items?
I really have no idea what's wrong with the node code :/

@rchougule
Copy link
Contributor

Hi @SassNinja,

We are working on updating few things at the back.
Meanwhile, add the following Accept header to make it work.

{
    url: 'https://api.browserstack.com/automate/builds?buildId=xxxx',
    method: 'DELETE',
    headers: {
      "Accept": "application/json"
    },
    auth: {
      user: username,
      pass: password
    }
  }

Let me know if you still face any issue.

Thanks for reaching out.
~ Rohan Chougule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants