It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Malformed JSON string while retrieving Crucible review data using REST Api's

Mohan Krishnan Jun 27, 2013

Hello ,

The following code snippet throws the following error :

my $headers = {Content-type => 'application/json' ,Accept => 'application/json', Authorization => 'Basic ' . encode_base64($username . ':' . $password)};

my $client = REST::Client->new();

$client->setHost('http://Cru_Server:8060/cru');

$client->GET('/rest-service/reviews-v1/filter/allOpenReviews',$headers);

#print $client->responseContent();

my $response = from_json($client->responseContent());

print $response;

malformed JSON string, neither array, object, number, string or atom, at charact

er offset 1 (before "<!DOCTYPE html>\n<ht...") at Crucible_Interaction.pl line

Any suggestion's?

Thanks ,

Mohan

4 answers

0 votes
Conor MacNeill Atlassian Team Jun 27, 2013

It looks like you are getting an error response. Can you look at the whole response. Usually there is a message in there regarding the error. You can alos look at the log on the server side to see what might be going wrong.

0 votes
Sergey Svishchev Jun 29, 2013

That's not a JSON response, by the way.

0 votes

Hi Mohan,

Are you using your REST client correctly? I'm not super familiar with perl, but I would assume that a method called setHost is not meant to take a URL path. You could try something like this:

$client->setHost('Cru_Server:8060');

$client->GET('/cru/rest-service/reviews-v1/filter/allOpenReviews',$headers);

You may also need to set the port separately to the host?

-Richard

0 votes
Mohan Krishnan Jul 02, 2013

Hi Sergey ,

how do i need to ensure that i get a JSON response ?

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

4,065 views 21 23
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you