File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,8 @@ protected function post(string $path, array $parameters = [])
132
132
{
133
133
$ response = $ this ->connection ->getHttpClient ()->post (
134
134
$ this ->getUri ($ path ),
135
- ['json ' => $ parameters ]
135
+ [],
136
+ $ this ->createJsonBody ($ parameters )
136
137
);
137
138
138
139
return ResponseMediator::getContent ($ response );
@@ -149,4 +150,18 @@ private function getUri(string $path): string
149
150
{
150
151
return '/ ' !== $ path [0 ] ? "/ {$ path }" : $ path ;
151
152
}
153
+
154
+ /**
155
+ * Create a JSON encoded version of an array of parameters.
156
+ *
157
+ * @param array $parameters Request parameters
158
+ *
159
+ * @return null|string
160
+ */
161
+ protected function createJsonBody (array $ parameters ): ?string
162
+ {
163
+ return (count ($ parameters ) === 0 )
164
+ ? null
165
+ : json_encode ($ parameters , empty ($ parameters ) ? JSON_FORCE_OBJECT : 0 );
166
+ }
152
167
}
You can’t perform that action at this time.
0 commit comments