I want to use confluence to automate some auditing of our enviroments but am running into errors when I try and upload data via the API.
Honestly i think i may be approaching this the wrong way so please feel free to correct me.
I am collecting data from AD then using the built in Convertto-html command. After a litle clean up my data looks like bellow
<head>
<title>HTML TABLE</title>
</head><body>
<table>
<colgroup><col/><col/><col/></colgroup>
<tr><th>SamAccountName</th><th>LastLogonDate</th><th>Description</th></tr>
<tr><td>Usern.nme1</td><td>13/10/2019 10:05:05</td><td>Fleet</td></tr>
<tr><td>Usern.nme2</td><td>18/09/2018 15:40:12</td><td>CSR Team
</table>
</body>
I then add this with some other data to a variable calle $body, which looks like the following:
{"type":"page","title":"90 day inactivity report", "version":{"number":7},"body":{"storage":{"value":"<head>
<title>HTML TABLE</title>
</head><body>
<table>
<colgroup><col/><col/><col/></colgroup>
<tr><th>SamAccountName</th><th>LastLogonDate</th><th>Description</th></tr>
<tr><td>Usern.nme1</td><td>13/10/2019 10:05:05</td><td>Fleet</td></tr>
<tr><td>Usern.nme2</td><td>18/09/2018 15:40:12</td><td>CSR Team
<tr><td>Usern.nme1</td><td>16/06/2018 17:54:21</td><td>CSR</td></tr>
</table>
</body>","representation":"storage"}}}And then issue the following to upload the data
Invoke-RestMethod https://jira.domain.co.uk/confluence/rest/api/content/45056041?expand=body.storage -Method Put -Headers $Headers -Body $body
and get this error
Invoke-RestMethod : The remote server returned an error: (500) Internal Server Error.
At line:1 char:1
My feeling is it doesnt like a character in the data, as i tried this with just "test" as the payload and it works without issue. but the error is so vague.
Can anyone tell me how could i:
- Get more informaiton from the API as to why a quiery falled
- Upload special characters via the API
- Just help in general
Thanks in advance