setting default branch returns "unknown field" error

Running this:

curl -u user:pwd -X PUT -H "Accept: application/json" -H "Content-type: application/json" -d "{\"name\":\"development\"}" http://git.somewhere.com/rest/api/1.0/projects/TM/repos/myrepo/branches/default

Yields this:

{"errors":[{"context":"name","message":"Unrecognized field \"name\" (Class com.atlassian.stash.rest.data.RestBranch), not marked as ignorable\n at [Source: org.apache.catalina.connector.CoyoteInputStream@18c82cf; line: 1, column: 10] (through reference chain: com.atlassian.stash.rest.data.RestBranch[\"name\"])","exceptionName":null}]}

The API browser offers no suggestion of what the field name is supposed to be. I've tried 'branch' and 'default' as the field name, neither of which work.

1 answer

1 accepted

1 votes
Seb Ruiz Atlassian Team Dec 17, 2012

Try this:

curl -u user:pwd -X PUT -H "Accept: application/json" -H "Content-type: application/json" -d "{\"id\":\"development\"}" http://git.somewhere.com/rest/api/1.0/projects/TM/repos/myrepo/branches/default

(the json should use the "id" property, not "name".

That worked. Thank you for your help.

Is there any way those field names could be documented somewhere, such as the API Browser?

Seb Ruiz Atlassian Team Dec 17, 2012

We will be documenting these fields, sorry for the inconvenience!

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

648 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot