Skip to content

Commit b4bb224

Browse files
committed
fix webservice request headers
1 parent 23dc2e7 commit b4bb224

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

app/Http/Controllers/Api/V1/SiteController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function register(SiteRequest $request): JsonResponse
3434
$url = $request->string('url');
3535
$key = $request->string('key');
3636

37-
$connectionService = App::makeWith(Connection::class, [$url, $key]);
37+
$connectionService = App::makeWith(Connection::class, ["baseUrl" => $url, "key" => $key]);
3838

3939
// Do a health check
4040
try {
@@ -49,7 +49,7 @@ public function register(SiteRequest $request): JsonResponse
4949
$site = new Site();
5050

5151
$site->key = $key;
52-
$site->url = $url;
52+
$site->url = rtrim($url, "/");
5353
$site->last_seen = Carbon::now();
5454

5555
// Fill with site info

app/RemoteSite/Connection.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,13 @@ public function performExtractionRequest(array $requestData): array
6767
]
6868
);
6969

70-
$responseData = $this->decodeResponse($response, $request);
71-
72-
return $responseData;
70+
return $this->decodeResponse($response, $request);
7371
}
7472

7573
protected function performWebserviceRequest(
7674
HttpMethod $method,
7775
string $endpoint,
78-
array $requestData = []
76+
?array $requestData = null
7977
): array {
8078
$request = new Request(
8179
$method->name,
@@ -89,7 +87,11 @@ protected function performWebserviceRequest(
8987
$response = $this->performHttpRequest(
9088
$request,
9189
[
92-
"json" => $requestData
90+
"json" => $requestData,
91+
"headers" => [
92+
"Content-Type" => "application/json",
93+
"Accept" => "application/vnd.api+json"
94+
]
9395
]
9496
);
9597

0 commit comments

Comments
 (0)