0

I'm trying to pass the following restart command that will run in a container, into a C# command, but I'm not sure how to do it, help please:

curl --header "Content-Type:application/json" "$BALENA_SUPERVISOR_ADDRESS/v2/applications/$BALENA_APP_ID/restart-service?apikey=$BALENA_SUPERVISOR_API_KEY" -d '{"serviceName": "venue"}'
7
  • Have you taken a look at HttpClient? Commented Aug 30, 2022 at 10:59
  • yes but I'm not sure how to implement it with the balena and json, I understand the -d '{"serviceName": "venue"}' is the task but not how to implement the rest Commented Aug 30, 2022 at 11:01
  • Take a look at the curl docs and -d specifies the content of a POST request which matches the Content-Type header which is also specified. Commented Aug 30, 2022 at 11:04
  • Would this be enought? using (var httpClient = new HttpClient()) { using (var request = new HttpRequestMessage(new HttpMethod("POST"), "http://$BALENA_SUPERVISOR_ADDRESS/v2/applications/$BALENA_APP_ID/restart-service?apikey=$BALENA_SUPERVISOR_API_KEY/")) { request.Content = new StringContent("{\"serviceName\": \"venue\"}"); request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); var response = await httpClient.SendAsync(request); } } Commented Aug 30, 2022 at 11:09
  • I'm just not sure if "$BALENA_SUPERVISOR_ADDRESS/v2/applications/$BALENA_APP_ID/restart-service?apikey=$BALENA_SUPERVISOR_API_KEY" should go into http Commented Aug 30, 2022 at 11:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.