diff --git a/service/lib/agama/http/clients/scripts.rb b/service/lib/agama/http/clients/scripts.rb index 7a78954f10..4e9cd22562 100644 --- a/service/lib/agama/http/clients/scripts.rb +++ b/service/lib/agama/http/clients/scripts.rb @@ -21,6 +21,7 @@ require "uri" require "net/http" +require "json" module Agama module HTTP @@ -28,12 +29,12 @@ module Clients # HTTP client to interact with the scripts API. class Scripts def initialize - @base_url = "http://localhost/api" + @base_url = "http://localhost/api/" end # Runs the scripts def run(group) - Net::HTTP.post(uri("/api/scripts/run"), group, headers) + Net::HTTP.post(uri("scripts/run"), group.to_json, headers) end private @@ -44,8 +45,8 @@ def uri(path) def headers @headers = { - Accept: "application/json", - Authorization: "Bearer #{auth_token}" + "Content-Type": "application/json", + Authorization: "Bearer #{auth_token}" } end diff --git a/service/test/agama/http/clients/scripts_test.rb b/service/test/agama/http/clients/scripts_test.rb index 93d20ce0d6..62d30da03d 100644 --- a/service/test/agama/http/clients/scripts_test.rb +++ b/service/test/agama/http/clients/scripts_test.rb @@ -33,9 +33,9 @@ describe "#run" do it "calls the end-point to run the scripts" do url = URI("http://localhost/api/scripts/run") - expect(Net::HTTP).to receive(:post).with(url, "post", { - Accept: "application/json", - Authorization: "Bearer 123456" + expect(Net::HTTP).to receive(:post).with(url, "post".to_json, { + "Content-Type": "application/json", + Authorization: "Bearer 123456" }) scripts.run("post") end