Jump to content
Sign in to follow this  
rewilliams

Retrieving a Password via API and Curl

Recommended Posts

Hello, I am able to pull passwords from passwordstate using powershell put am unable to pull via curl. Can someone please help me convert this?

 

This Works in powershell: 

$PasswordstateUrl = 'https://passwordstate.example.com/api/passwords/1111'
Invoke-Restmethod -Method GET -Uri $PasswordstateUrl -Header @{ "APIKey" = "fdafdasfqewfsdfsd6" }

 

Thanks,

 

 

Share this post


Link to post
Share on other sites

Here are some of the commands that i've tried.

 

curl  -k -sS --request GET https://passwordstate.example.com/api/passwords/1111 -d "apikey=fdafdasfqewfsdfsd6"

 

[{"errors":[{"message":"No Authorization"},{"phrase":"An error has occurred trying to validate the API Key for PasswordID '3481'. Please check the PasswordID and API Key values have been specified, and are correct."}]}]

 

 

curl -v -k -sS --request GET https://passwordstate.example.com/api/searchpasswords/1111/title="abcdinst GPG Passphrase" -d "apikey=fdafdasfqewfsdfsd6"

<hr><p>HTTP Error 400. The request is badly formed.</p>

 

 

Share this post


Link to post
Share on other sites

Hello,

 

We don't have much experience with Curl, but for your first command, can you try changing the -d to a -H - the API Key can be set either in the URL (not recommended), or the Header Request. And in curl, I think this is a -H for header request.

 

The second issue may be spaces in the title field search, but I cannot be sure. Below is some old documentation for searching with curl, but again the API Key should go in the header request.

 

# General Search by Password List
    curl https://passwordstate/api/searchpasswords/<PasswordListID>?search=<value>&apikey=<value>
                                
    # General Search across all Password Lists and all Fields (must use System Wide API Key) 
    curl https://passwordstate/api/searchpasswords/?search=<value>&apikey=<value>

    # Specific Search, by 'Title', within a Password List
    curl https://passwordstate/api/searchpasswords/<PasswordListID>?title=<value>&apikey=<value>

    # Specific Search, by 'Username', within a Password List
    curl https://passwordstate/api/searchpasswords/<PasswordListID>?username=<value>&apikey=<value>

    # Specific Search, by 'Title' and 'Username', across all Password Lists (must use System Wide API Key)
    curl https://passwordstate/api/searchpasswords/?title=<value>&username=<value>&apikey=<value>

 

Regards

Click Studios

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...