Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

Unauthorized (401) #6

Closed
deadmerc opened this issue Jan 15, 2018 · 3 comments
Closed

Unauthorized (401) #6

deadmerc opened this issue Jan 15, 2018 · 3 comments

Comments

@deadmerc
Copy link

Hi,
have trouble, with secure request.
I am using
$client = new JWTClient(Auth::user());
dump($client->post('/rest/api/2/search'.urlencode('?jql=updated > 2014-01-20 and project in (PC) and timespent > 0&fields=summary,worklog&maxResults=1000')));
I got 401, can you please help me with it? Interesting, what
dump($client->get('/rest/api/2/issue/TEST-13'));
works perfectly, problem in jira permissions?

@breart
Copy link
Owner

breart commented Jan 15, 2018

Hi @deadmerc,

That's because you're trying to pass query parameters to URL, you should use the parameter $config instead:

$client = new JWTClient(Auth::user());
$client->post('rest/api/2/search', [], [
    'query' => [
        'jql' => 'updated > 2014-01-20 and project in (PC) and timespent > 0',
        'fields' => 'summary,worklog',
        'maxResults' => '1000'
    ]
]);

You can see all the available options at Guzzle HTTP documentation.

Btw, the same issue: #4

@deadmerc
Copy link
Author

Thanks for fast response @brezzhnev , but it not working
Your example return
Unrecognized field "query" (Class com.atlassian.jira.rest.v2.search.SearchRequestBean), not marked as ignorable
Tried without query
Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token
This request have GET method, it not working too.

@breart
Copy link
Owner

breart commented Jan 16, 2018

@deadmerc when I using GET method it also doesn't work for me, strange.

You could try this, it works for me:

$client = new JWTClient(Auth::user());
$response = $client->post('rest/api/2/search', [
    'jql' => 'updated > 2014-01-20 and project in (PC) and timespent > 0',
    'fields' => ['summary', 'worklog'],
    'maxResults' => '1000'
]);

Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token

This error was due to fields parameter. When you're performing POST request, you should use an array instead of the string with commas.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants