Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
249 views
in Technique[技术] by (71.8m points)

How to check Spring Actuator content with Powershell

I want to check the baseurl/actuator/info endpoint for my application in a powershell script.

I have tried running the following command

(iwr -Uri $url).Content

but run into the following issues

  1. The data returned appears to be ascii values or something with each value on it's own line
  2. The data returned appears to be html instead of json

Using postman the data is returned just fine. But how can I achieve this in Powershell?

question from:https://stackoverflow.com/questions/65886884/how-to-check-spring-actuator-content-with-powershell

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I suspect the info endpoint decides on the output format based on the request you send it, so try:

(iwr -Uri $url -ContentType application/json -Headers @{ Accept = 'application/json' }).Content

Now that Spring knows it's talking to a JSON client, it should send JSON back


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...