Bitbucker REST API to Commit Files with custom email

40 Views Asked by At

I am using Springboot service which connects to Bitbucket via REST API to commit file . This works perfectly when I use the token of a user which has a email associated with it.

I have a usecase when a common Id will be used for commit and it will not have a email associated with it in Bitbucket profile and I wont be able to update the Bibucket profile.

I need to commit using the common ID using the REST API by giving custom email ID .

Below is the sample code snippet

  MultiValueMap<String, String> formData = new LinkedMultiValueMap<>();
        formData.add("message", message);
        formData.add("branch", branch);
        formData.add("content", content);
        formData.add("author.name", authorName);
        formData.add("author.email", authorEmail);

        HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(formData, headers);

        String apiUrl ={{BITBUCKET_URL}} // with file name at the end

        ResponseEntity<String> response = restTemplate.exchange(apiUrl, HttpMethod.POST, requestEntity, String.class);

Error:

When performing an edit, the author must have an valid email address

Tried the above snippet by injecting the author in formdata but it does not work

0

There are 0 best solutions below