Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confluence returned HTTP error 400 - BadRequest #158

Open
1 task done
braveadmin opened this issue Dec 11, 2018 · 23 comments
Open
1 task done

Confluence returned HTTP error 400 - BadRequest #158

braveadmin opened this issue Dec 11, 2018 · 23 comments

Comments

@braveadmin
Copy link

braveadmin commented Dec 11, 2018

Description

I noticed that Set-ConfluencePage command doesn't work at all, maybe for a bug.

If I do a get of a certain PageID it works without problem, but when i do the following command it prompts me the following bellow

Steps To Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

Screenshots

image

Your Environment

Get-Module ConfluencePS -ListAvailable | Select Name, Version
Name         Version
----         -------
ConfluencePS 2.3.6  

$PSVersionTable
Name                           Value                                           
----                           -----                                           
PSVersion                      5.1.16299.785                                   
PSEdition                      Desktop                                         
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                         
BuildVersion                   10.0.16299.785                                  
CLRVersion                     4.0.30319.42000                                 
WSManStackVersion              3.0                                             
PSRemotingProtocolVersion      2.3                                             
SerializationVersion           1.1.0.1  

Confluence Server:

  • version: unknown
  • is cloud server

Possible Solution

@lipkau
Copy link
Member

lipkau commented Dec 11, 2018

Please update the "Your Environment" in the template.

@lipkau
Copy link
Member

lipkau commented Dec 11, 2018

Please run the command with -Debug enabled:

Set-ConfluencePage -PageId 616493147 -Body 'test' -debug

enter suspend mode on the 2nd time this message shows up:

DEBUG: [Invoke-Method] Executed WebRequest. Access $webResponse to see details

(the first is for Get-Page and the 2nd for Set-Page)

Once in suspend, please post here the output of

$iwParameters
$body

@braveadmin
Copy link
Author

braveadmin commented Dec 11, 2018

This is the output:

PS C:\Windows\system32>> Set-ConfluencePage -PageID $PageID -Body $Body -Debug
DEBUG: [Set-ConfluencePage] ParameterSetName: byParameters
DEBUG: [Set-ConfluencePage] PSBoundParameters: 
Key                                            Value
---                                            -----
PageID                                     616493147
Body                                            Test
Debug                                           True
apiURi            https://confluence.ntt.eu/rest/api
Credential System.Management.Automation.PSCredential



DEBUG: [Get-Page] ParameterSetName: byId
DEBUG: [Get-Page] PSBoundParameters: 
Key        Value                                    
---        -----                                    
PageID     {616493147}                              
ApiURi     https://confluence.ntt.eu/rest/api       
Credential System.Management.Automation.PSCredential



DEBUG: [Invoke-Method] ParameterSetName: __AllParameterSets
DEBUG: [Invoke-Method] PSBoundParameters: 
Key                                                              Value
---                                                              -----
First                                             18446744073709551615
GetParameters                                          {expand, limit}
Method                                                             Get
Skip                                                                 0
URi               https://confluence.ntt.eu/rest/api/content/616493147
IncludeTotalCount                                                False
Credential                   System.Management.Automation.PSCredential
OutputType                                           ConfluencePS.Page



DEBUG: [Invoke-Method] Using $GetParameters: 
Name                           Value                                           
----                           -----                                           
expand                         space,version,body.storage,ancestors            
limit                          25                                              



DEBUG: [Invoke-Method] Executed WebRequest. Access $webResponse to see details
PS C:\Windows\system32>>> $iwParameters
$body

Name                           Value                                           
----                           -----                                           
First                          18446744073709551615                            
GetParameters                  {expand, limit}                                 
Method                         Get                                             
Skip                           0                                               
Uri                            https://confluence.ntt.eu/rest/api/content/61...
IncludeTotalCount              False                                           
Credential                     System.Management.Automation.PSCredential       
OutputType                     ConfluencePS.Page   

@lipkau
Copy link
Member

lipkau commented Dec 12, 2018

you stopped at the first message

DEBUG: [Invoke-Method] Executed WebRequest. Access $webResponse to see details

I need the $body and $iwParameters of the 2nd time that message is shown

@braveadmin
Copy link
Author

braveadmin commented Dec 12, 2018

sorry, this is the result:

DEBUG: [Set-ConfluencePage] ParameterSetName: byParameters
DEBUG: [Set-ConfluencePage] PSBoundParameters: 
Key                                            Value
---                                            -----
PageID                                     616493147
Body                                            Test
Debug                                           True
apiURi            https://confluence.ntt.eu/rest/api
Credential System.Management.Automation.PSCredential



DEBUG: [Get-Page] ParameterSetName: byId
DEBUG: [Get-Page] PSBoundParameters: 
Key        Value                                    
---        -----                                    
PageID     {616493147}                              
ApiURi     https://confluence.ntt.eu/rest/api       
Credential System.Management.Automation.PSCredential



DEBUG: [Invoke-Method] ParameterSetName: __AllParameterSets
DEBUG: [Invoke-Method] PSBoundParameters: 
Key                                                              Value
---                                                              -----
First                                             18446744073709551615
GetParameters                                          {expand, limit}
Method                                                             Get
Skip                                                                 0
URi               https://confluence.ntt.eu/rest/api/content/616493147
IncludeTotalCount                                                False
Credential                   System.Management.Automation.PSCredential
OutputType                                           ConfluencePS.Page



DEBUG: [Invoke-Method] Using $GetParameters: 
Name                           Value                                           
----                           -----                                           
expand                         space,version,body.storage,ancestors            
limit                          25                                              



DEBUG: [Invoke-Method] Executed WebRequest. Access $webResponse to see details
DEBUG: [Set-ConfluencePage] Content to be sent: 
Name                           Value                                           
----                           -----                                           
type                           page                                            
version                        {number}                                        
ancestors                      {}                                              
body                           {storage}                                       
title                          Llistat IP - Cloud Nexica - Test                



DEBUG: [Invoke-Method] ParameterSetName: __AllParameterSets
DEBUG: [Invoke-Method] PSBoundParameters: 
Key                                                                       Value
---                                                                       -----
Method                                                                      Put
Credential                            System.Management.Automation.PSCredential
URi                        https://confluence.ntt.eu/rest/api/content/616493147
Body                                                                       {...
OutputType                                                    ConfluencePS.Page



DEBUG: [Invoke-Method] Executed WebRequest. Access $webResponse to see details
PS C:\Windows\system32>>>> $Body
{
    "type":  "page",
    "version":  {
                    "number":  4
                },
    "ancestors":  [

                  ],
    "body":  {
                 "storage":  {
                                 "representation":  "storage",
                                 "value":  "Test"
                             }
             },
    "title":  "Llistat IP - Cloud Nexica - Test"
}

PS C:\Windows\system32>>>> $iwParameters

Name                           Value                                           
----                           -----                                           
Method                         Put                                             
Credential                     System.Management.Automation.PSCredential       
Uri                            https://confluence.ntt.eu/rest/api/content/61...
Body                           {...                                            
OutputType                     ConfluencePS.Page 

@lipkau
Copy link
Member

lipkau commented Dec 17, 2018

I can't figure out what is going on.
What does this return?

get-confluencepage -PageID 616493147 | select -exclude body

@braveadmin
Copy link
Author

braveadmin commented Dec 19, 2018

PS C:\Users\braveadmin> get-confluencepage -PageID 616493147 | select -exclude body

ID         Status    Title                                SpaceKey        Version   
--         ------    -----                                --------        -----
616493147            Llistat IP - Cloud Nexica - Test     AOC             3   

@lipkau
Copy link
Member

lipkau commented Dec 19, 2018

does this happen to every page on that wiki server? or in that same space?

@braveadmin
Copy link
Author

I tried with other pages, even with test pages created exclusively to test this. In every case I got the same error.
I can do a Get-ConfluencePage but Set-ConfluencePage doesn't work.

@lipkau
Copy link
Member

lipkau commented Dec 20, 2018

@braveadmin : can you confirm that this still happens on the latest version? (2.4.0)

@brianbunke : can you reproduce this?

@braveadmin
Copy link
Author

Hi @lipkau
do you mean ConfluencePS version?

@lipkau
Copy link
Member

lipkau commented Jan 4, 2019

yes

@braveadmin
Copy link
Author

I got the same error. "Edit content id mismatch".

@brianbunke
Copy link
Collaborator

I cannot reproduce. Set-ConfluencePage -PageId 616493147 -Body 'test test' works as expected for me on ConfluencePS 2.4.0 and Confluence Server 6.10.0. My $Body and $iwParameters debug output looks identical.

@braveadmin
Copy link
Author

Any suggestion on what could be going wrong? @brianbunke @lipkau

@braveadmin
Copy link
Author

which version of powershell did you use to test it?

@lipkau
Copy link
Member

lipkau commented Jan 23, 2019

I can run it successfully on PSv5.1 and v6.1
against a Cloud server and an On-Premise Server v6.2.4

@braveadmin
Copy link
Author

Which minimum version of Confluence Server is compatible with ConfluencePS? @brianbunke

@lipkau
Copy link
Member

lipkau commented Jan 25, 2019

There is no way to really know this.
I can be wrong, but would expect all version > 6 to work properly.
I have tried finding old versions of the API documentation, but this is not trivial

@lipkau
Copy link
Member

lipkau commented Feb 10, 2019

What is the version of the confluence server?

You should be able to see it in the footer of pretty much every page

@rjdlobik
Copy link

rjdlobik commented Oct 1, 2019

I'm also receiving a 400 bad request when attempting to retrieve a page by label. I've included the request and response below:

$response = Get-ConfluencePage -Label 'noarchive-single'

WARNING: Confluence returned HTTP error 400 - BadRequest
Invoke-Method : Could not parse cql : type=page AND label=noarchive-single
At C:\Program Files\WindowsPowerShell\Modules\ConfluencePS\2.5.0\ConfluencePS.psm1:772 char:17

  •             Invoke-Method @iwParameters
    
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidResult: ({"statusCode":4...:"Bad Request"}:String) [Invoke-Method], ArgumentException
    • FullyQualifiedErrorId : InvalidResponse.Status400,Invoke-Method

@MortenRei
Copy link

I have the exact samme problem as the rest here. Did anyone manage to solve the problem?

@ehrenfeu
Copy link

@rjdlobik are you sure you are referring to the same problem here? Your issue looks more like the hyphen quoting problem described in #175

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

No branches or pull requests

6 participants