Jump to content

API - Updating field


Recommended Posts

Hi,

 

I tried to update some field with api, i use this command but powershell tell me some error with Put Method

 

    # PowerShell Request

    #JSON data for the object
    $jsonData = '
    {
	"PasswordID":"46411",
	"password":"JENN-ZHn#3+A^yc",
        "APIKey":"<apikey>"	    
    }
    '

    $PasswordstateUrl = 'https://passwordstate/api/passwords'
    $result = Invoke-Restmethod -Method Put -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData

 

Can you tell me how updating some field (like "notes" or "custom field"...)

Thanks and sorry for english...

 

Link to comment
Share on other sites

Hello,

 

You just need to add in the extra fields into this jsonObject, like below"

 

$jsonData = '
    {
         "PasswordID":"46411",
         "password":"JENN-ZHn#3+A^yc",

          "Notes":"Notes 123",
          "GenericField1":"custom field data",
         "APIKey":"<apikey>"        
    }
    '

We hope this helps.

Regards

Click Studios

Link to comment
Share on other sites

Hi,

 

You might need to google the actual error for this, as PowerShell does support the Put method - we use it all the time, as well as other customers as well.

Unless you have some load balancers or proxy servers which are causing issues with this?

Regards

Click Studios

Link to comment
Share on other sites

I try to search in Google but cant find anything

 

+ ...   $result = Invoke-Restmethod -Method Put -Uri $PasswordstateUrl -Con ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation : (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Link to comment
Share on other sites

Script

    # PowerShell Request

    #JSON data for the object
    $jsonData = '
    {
    "PasswordID":"94",
    "password":"JENN-ZHn#3+A^yc",
    "APIKey":"<apikey>"        
    }
    '

    $PasswordstateUrl = 'https://myurl/api/passwords'
    $result = Invoke-Restmethod -Method Put -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData

 

 

Powershell version 

Name                           Value                                                                                                                                                                                                                             
----                           -----                                                                                                                                                                                                                             
PSVersion                      5.1.17134.590                                                                                                                                                                                                                     
PSEdition                      Desktop                                                                                                                                                                                                                           
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                                           
BuildVersion                   10.0.17134.590                                                                                                                                                                                                                    
CLRVersion                     4.0.30319.42000                                                                                                                                                                                                                   
WSManStackVersion              3.0                                                                                                                                                                                                                               
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                                               
SerializationVersion           1.1.0.1    

 

image.thumb.png.5f1bc9aa926e807aaeac6ad256c0d2bc.png

 

Link to comment
Share on other sites

Don't have better than that :

 

Invoke-Restmethod : La page que vous recherchez ne peut pas être affichée, car une méthode non valide (verbe HTTP) est utilisée.
Au caractère Ligne:13 : 15
+ ...   $result = Invoke-Restmethod -Method Put -Uri $PasswordstateUrl -Con ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation : (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Link to comment
Share on other sites

Thanks. Is your Passwordstate URL direct to the web server, and not going through a Proxy Server or Load Balancer? Something is rejecting this API Call, and it would not be Passwordstate as it is core functionality for the API.

 

Regards

Click Studios

Link to comment
Share on other sites

Hello,

 

Each of these Handler Mappings have different settings, so I'm not sure which one you've selected in your screenshot to compare against?

 

If you want, you can follow these instructions for moving your install of Passwordstate, in case there are issues with your IIS configuration - I wish we could tell you the cause of this, but we're simply not sure sorry.

 

https://www.clickstudios.com.au/documentation/move-new-web-server.aspx

https://www.clickstudios.com.au/documentation/move-new-database-server.aspx 

Regards

Click Studios

Link to comment
Share on other sites

  • 3 weeks later...

Hello,

 

Sorry, we're not sure where in IIS you are seeing this restriction, but it is not a default setting for IIS.

If you cannot move you install to a new web server, could you please log a support call with Microsoft and they might be able to help you with this - we're simply not sure sorry.

Regards

Click Studios

Link to comment
Share on other sites

  • 1 year later...

Hiya! I found this thread while troubleshooting the same problem so I thought I'd add what ended up working for me:

 

I'm running Windows Server 2016, and apparently there is a "feature" called WebDAV that often filters PUT requests, even if you disable it! I ended up having to fully remove it. To do this:

  • Open Server Manager and in the upper right go to Manage > Remove Roles And Features
  • WebDAV can be found under Web Server (IIS) > Web Server > Common HTTP Features > WebDAV Publishing. Once it is uninstalled, you will have to reboot the server (not just restart IIS, sadly).

Hope this helps someone!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...