It's all about the answers!

Ask a question

Getting 400 Unauthorized error while creating baseline on GC stream using Rest/OSLC APIs


KT PD (597) | asked May 31 '23, 4:53 a.m.
edited May 31 '23, 4:58 a.m.
 Hi Team,

We are using IBM tool chain with version 7.0.2.
We are trying to create baseline using POST method on GC streams with following details:

1. Method: POST
2. URL: https://<Server_name>/gc/api/createBaseline
3. Body:"@prefix oslc_config_ext:  <http://jazz.net/ns/config_ext#>
<https://<Server_name>/gc/api/createBaseline>
    oslc_config_ext:titleTemplate "{0} Example baseline (2023-05-31)" ;
    oslc_config_ext:rootConfiguration <https://<Server_name>/gc/configuration/12>" 
4.Content-Type:text/turtle

Using this we are getting below error:
400 unautherised
After giving credentials also it is not able to create
Anyone please help me

Thanks

Comments
Michael Rowe commented May 31 '23, 8:07 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR

What authentication are you using?  All POSTs do require authentication with the server. 


KT PD commented May 31 '23, 12:33 p.m. | edited Jun 01 '23, 4:10 a.m.

 I am using basic auth method

Other Post requests are working using same.


Michael Rowe commented May 31 '23, 1:37 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR

Have you confirmed that the user id you are passing in the POST has permission to create baselines in the project area you are executing against? 


KT PD commented May 31 '23, 3:02 p.m.

Yes that userid is having all configuration related permissions including creating baselines 


KT PD commented May 31 '23, 10:16 p.m. | edited Jun 01 '23, 4:10 a.m.

 Hi,

Anyone let me know the body I am passing in post method is correct or need some modifications

Thanks 

Accepted answer


permanent link
Ian Barnard (1.9k613) | answered Jun 01 '23, 4:06 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jun 01 '23, 4:07 a.m.

You're missing a space and a dot (period) on the end of your prefix line - without that I get a 500 error. If you get a 403 error read the response content and add the header it tells you to.


@prefix oslc_config_ext:  <http://jazz.net/ns/config_ext#> .
<https://<Server_name>/gc/api/createBaseline>
    oslc_config_ext:titleTemplate "{0} Example baseline (2023-05-31)" ;
    oslc_config_ext:rootConfiguration <https://<Server_name>/gc/configuration/12>

With it I get the expected 200 response and the Location header in the response gives the tracker; the baseline is created. I have to change the titleTemplate to create another new baseline because it quite reasonably won't let you create a baseline with an already-existing title.

Not sure how you get a 400 error; perhaps basic auth isn't working.

KT PD selected this answer as the correct answer

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.