Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Invalid UTF-8 start byte 0xa0 Confluence REST API

Ayaskant Swain May 24, 2018

Hi ,

I am getting the below error in Confluence logs while trying to create content in Confluence via it's REST API. I have written a Java client that makes the REST API call to https://<our_confluence_host>/confluence/rest/api/content with json paylaod to craete a page. It uses apache httpclient to make the call.

Below are the http request headers :

request.setHeader("Accept", "application/json");

request.setHeader("Content-Type", "application/json"); 

HttpResponse response = httpClient.execute(request);

 

I am getting http status code 500. The Confluence server's application logs prints the below stacktrace. This is an blocker issue for us. Any help is highly appreciated.

I even tried setting "Content-Type" header as "application/json:charset=UTF-8" but taht also did not help.

2018-05-24 10:20:52,760 ERROR [http-nio-8090-exec-8] [rest.api.model.ExceptionConverter] convertServiceException No status code found for exception, converting to internal server error :
-- url: /confluence/rest/api/content | traceId: 8f2a32f5543f5461 | userName: _stagegitportal
org.codehaus.jackson.JsonParseException: Invalid UTF-8 start byte 0xa0
at [Source: com.atlassian.confluence.plugins.restapi.filters.LimitingRequestFilter$1@50455f9c; line: 1, column: 951]
at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1433)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)
at org.codehaus.jackson.impl.Utf8StreamParser._reportInvalidInitial(Utf8StreamParser.java:2825)
at org.codehaus.jackson.impl.Utf8StreamParser._reportInvalidChar(Utf8StreamParser.java:2819)
at org.codehaus.jackson.impl.Utf8StreamParser._finishString2(Utf8StreamParser.java:1978)
at org.codehaus.jackson.impl.Utf8StreamParser._finishString(Utf8StreamParser.java:1905)
at org.codehaus.jackson.impl.Utf8StreamParser.getText(Utf8StreamParser.java:276)

1 answer

0 votes
Thomas Deiler
Community Champion
May 24, 2018

Dear @Ayaskant Swain,

it seems that the JSON data you send is not correctly encoded. Try

URLEncoder.encode(data,"UTF-8");

before executing the request, Btw: The header seems to be fine,

So long

Thomas

Ayaskant Swain May 25, 2018

Hi Thomas,

 

I tried that but it did not work either :-( . Strangely the same jsonpayload works when i call the API via POSTMAN. Page is created successfully in Confluence.

The POSTMAN sends the below headers.

headers = {
'content-type': "application/json",
'accept': "application/json",
'cache-control': "no-cache",
'postman-token': "34a891d4-52f1-649e-3fff-298f207ac2a5"
}

 

The "cache-control" and "postman-token" headers have been added by POSTMAN internally. I don't think they are making any difference and should be added in my Java client program.

The json request payload is below:

 

{\"type\":\"page\",\"title\":\"ECMC TROUBLESHOOTING PROCEDURES_30\",\"space\":{\"key\":\"DEVPROD\"},\"body\":{\"storage\":{\"value\":\"h1. NOT WORKING\\n\\nFor most of the possible problems below, start with these steps.\\n\\n* Check when the config was last updated.\\n* Check to see how long the current config is active.\\n* If the current production config was recently activated, run a diff to compare the current with previous active config.\\n\\nh2. VERIFY_CONFIG_ACTIVATION\\n|| Action || Result ||\\n| \\n# Log in to the ECMC and see if the configuration file containing the digital property having problems was recently changed.  \\n# Select View Details and look at the data of the more resent revision pushed to production | \\n# If a recent change was made, the timestamp will be recent, or the configuration may still be propagating to the network. |\\n\\nh2. VERIFY_ORIGIN_IP_CHANGES\\n|| Action |","representation":"wiki"}}}

 

Thanks

Ayaskant

Thomas Deiler
Community Champion
May 25, 2018

Dear @Ayaskant Swain,

probably its a JVM properties issue - but this is just a wild guess. If you paste the whole class, where you construct the request, I can probably help you debugging.

So long

Thomas

sudheer gaddam
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!
February 15, 2019

Can someone help in this regard?

Thomas Deiler
Community Champion
February 18, 2019

Dear @sudheer gaddam ,

where do you need help?

So long

Thomas

Yash Roy
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!
April 26, 2021

@Ayaskant Swain  @Thomas Deiler  

Hi, I am using post method when I am passing the same payload using postman it is creating the account. but when I am creating using python code it is giving 400 error and UTA-8 start byte 0xa0 at column line1 and column 118.

I am creating three tickets passing two are passing and 1 is failing, and my pay load is

This is the error payload where the ticket is not creating. 

{"fields": {"project": {"key": "ABC"},"parent": {"key": "ABC-19"}, "summary": "Update Release Calendar  - A B Platform - 4.0","description": " Release calendar gets updated here - https://confluence.xyz.com/display/AB/Release+Calendar","issuetype": { "name": "Sub-task","subtask": true},"assignee": {"name": "RAM"}, "labels":["PAYLOAD", "XYZ"]}}

These are my headers

'Cache-Control': 'no-cache',
'Authorization': jira_auth,
'Cookie': jira_cookie,
'Content-Type': 'application/json',
'Accept': '*/*',

 

Can you help me with this

Yash Roy
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!
April 26, 2021

Hey I got solution the only thing is, i am adding one additional space bar in my text.

BhavaniM
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!
December 9, 2021

Which text?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events