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

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

This widget could not be displayed.

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.

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

Hi Sergey ,

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

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

139 views 2 0
Join discussion

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