HPE OneView
1753797 Members
8752 Online
108805 Solutions
New Discussion

Re: Set default login directory

 
SOLVED
Go to solution
BhaskarV
Trusted Contributor

Re: Set default login directory

hi @BradV 

I wasnt expecting to see the "ADHQ=" in the error.

My request looks like this

curl -k -X POST \
--header "Content-Type:application/json" \
--header "X-API-Version:800" \
--header "Auth:xyz" \
--data '"ADHQ"' 'https://myappliance.hpe.com/rest/logindomains/global-settings/default-login-domain'

Can you check and compare against what you send to the server after all the substitutions?
ADHQ is the name of the directory that I want to be set as default.

Regards,
Bhaskar


I am an HPE employee

Accept or Kudo

ChrisLynch
HPE Pro

Re: Set default login directory

Changing any setting within OneView via the API requires authorization.  Your account needs to have Infrastructure administrator role.

As for setting the default auth directory for the appliance, you need to just encapsulate the directory name in double-quotes:

 

--data "ADHQ"

 

 

Otherwise, the API will be wanting to look for 'ADHQ', not just ADHQ.

Also, when providing code, either use the Insert Code button (which is the </> icon), or use another font type like Courier New.


I am an HPE employee

Accept or Kudo

BradV
Esteemed Contributor

Re: Set default login directory

Hi Chris,

I was just pointing out that the API Reference is invalid again. 

It says: 

 

Authorization
This API requires no authorization.

 

then in the Request Headers section: 

 

Auth   Session authorization token obtained from logging in.  If this header is not included or if the session-token is invalid, the response code will be 401 Unauthorized.

 

 So, inconsistent.

Bashkar/Chris, 

I am just using --data "ADHQ."  I believe the API reference example is also missleading.  It shows including the header, Content-Type: application/json.  The single name is not a valid json.  So, if I include that header, I get malformed json as the error.  

If I run: 

 

curl --insecure \
     --header "X-API-Version: ${currentVersion}" \
     --header "auth: ${sessionID}" \
     --data "ADHQ" \
     --request POST ${OneView}/rest/logindomains/global-settings/default-login-domain | jq -r '.'

 

I get the error with "errorSource": "ADHQ=" in the response.  I don't see any difference between what I have and what you presented other than the json header?

BhaskarV
Trusted Contributor

Re: Set default login directory

Hi @BradV 

In this specific case, you need an extra pair of single quotes enclosing the "ADHQ".  It needs to be <single quote>"ADHQ"<single quote>. Substitute all the variables, form a command line that works, then go back and fix the script accordingly.

curl --insecure \
--header "X-API-Version: 800" \
--header "auth: XYZ" \
--data '"ADHQ"' \
--request POST ${OneView}/rest/logindomains/global-settings/default-login-domain | jq -r '.' 

The below reliably works.

curl -k -X POST --header "Content-Type:application/json" --header "X-API-Version:800" --header "Auth:XYZ" --data '"ADHQ"' 'https://myappliance.hpe.com/rest/logindomains/global-settings/default-login-domain'

Try it out and let me know.

Regards,
Bhaskar


I am an HPE employee

Accept or Kudo

BradV
Esteemed Contributor

Re: Set default login directory

Hi Bashkar,

I finally got it worked out.  The REST API documentation needs updated.  First, correct the information about authorization.  Next is the content type header.  When I included content type header of application/json, I always got back malformed json since a single word is not a valid json.  So, I just dropped that header, but kept getting back invalid global settings and the errorsource was ADHQ=.  This worked: 

DATA="ADHQ"
curl --insecure \
     --header "content-type: text/plain" \
     --header "X-API-Version: ${currentVersion}" \
     --header "auth: ${sessionID}" \
     --data "${DATA}" \
     --request POST ${OneView}/rest/logindomains/global-settings/default-login-domain | jq -r '.'

Thanks for the help!

BhaskarV
Trusted Contributor

Re: Set default login directory

Great! Thanks a lot @BradV 

Regards,
Bhaskar


I am an HPE employee

Accept or Kudo

BradV
Esteemed Contributor

Re: Set default login directory

Hi Bashkar,

So, just to make sure, someone is entering a change request for the REST API documentation to fix the information on authorization, change the header information to show that header content-type: text/plain is required, and give a valid example?

Thanks!

BhaskarV
Trusted Contributor

Re: Set default login directory

hi @BradV

Yes, the error with the REST API documentation about authorization is being corrected.
On the content type, checking on the version of curl we use.

Regards
Bhaskar


I am an HPE employee

Accept or Kudo

BradV
Esteemed Contributor

Re: Set default login directory

Hi Bashkar,

If it helps, I am running on a RHEL 6.10 server with curl 7.19.7.  I wouldn't think that the version of curl would matter?  The content supplied was not a JSON.  It was just plain text.

Regards,

Brad