Bitbucket error: Unexpected character encountered while parsing value: <. Path '', line 0, position

Mark Mindlin October 19, 2021

We use Atlassian.Stash - C# API wrapper for Atlassian Stash, version v4.0.30319

C# .Net 4.8, Windows 10/1909

We migrated from Bitbucket Server to Bitbucket org, and have the error: Unexpected character encountered while parsing value: <. Path '', line 0, position 0

 try
{
var client = new StashClient(ConfigParametres.GitBaseURL, username, password);
ResponseWrapper<Atlassian.Stash.Entities.Commit> allCommits = await client.Commits.Get("PROJECT_KEY", "REPOSITORY_NAME", null, null);
if (allCommits.Values == null)
{
return false;
}
}
catch (Exception ex)
{
return false;
}

2 answers

0 votes
cleverstarfish
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 23, 2022

I solve this issue by removing # and $ characters from my password. 

0 votes
Ulrich Kuhnhardt _IzymesCo_
Atlassian Partner
October 20, 2021

Hi Mark,

Bitbucket Server aka Stash and Bitbucket cloud are 2 different products with 2 completely different REST APIs. Any client written to work with Bitbucket Server will not work as the URL paths will be completely different.

I would expect you will get a 404 not found HTML page as a response which cannot be parsed.

Here is the BBCloud REST API https://developer.atlassian.com/bitbucket/api/2/reference/

I'm not aware of a ready-to use client, but it may be out there.

Mark Mindlin October 20, 2021

Hi Ulrich,

 

We used https://github.com/jlouros/StashApiCSharp

Do you know about BBCloud analogue? I mean C# library.

Ulrich Kuhnhardt _IzymesCo_
Atlassian Partner
October 20, 2021

Unfortunately not, Mark.

Mark Mindlin October 28, 2021

We switched to another library

https://github.com/lvermeulen/Bitbucket.Cloud.Net

But there is an error when calling GetRepositoryCommitsAsync()

Source "Flurl.Http"

Message "Response could not be deserialized to JSON: GET https://bitbucket.org/2.0/repositories/bxbts/smscore/commits"

InnerException

Source "Newtonsoft.Json"

StackTrace

at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonTextReader.Read()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
at Flurl.Http.Configuration.NewtonsoftJsonSerializer.Deserialize[T](Stream stream)
at Flurl.Http.HttpResponseMessageExtensions.<ReceiveJson>d__0`1.MoveNext()

Message "Unexpected character encountered while parsing value: <. Path '', line 0, position 0." 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events