@@ -139,18 +139,17 @@ public function __call($name, $arguments)
139139 case 'POST ' :
140140 case 'PUT ' :
141141 // JSON or Form_params mappings
142-
143- if ($ requestType == 'form_data ' ){
142+
143+ if ($ requestType == 'form_data ' ) {
144144
145145 $ json = $ this ->processFormParamsMappings ($ arguments , $ api );
146146
147- $ object = $ this ->call ($ method ,$ uri ,['form_params ' => $ json ]);
148- }
149- else {
147+ $ object = $ this ->call ($ method , $ uri , ['form_params ' => $ json ]);
148+ } else {
150149
151- $ json = $ this ->processJsonMappings ($ arguments , $ api );
152- // Call the API
153- $ object = $ this ->call ($ method , $ uri , ['json ' => $ json ]);
150+ $ json = $ this ->processJsonMappings ($ arguments , $ api );
151+ // Call the API
152+ $ object = $ this ->call ($ method , $ uri , ['json ' => $ json ]);
154153 }
155154
156155 break ;
@@ -160,7 +159,7 @@ public function __call($name, $arguments)
160159 // Call the API
161160 $ object = $ this ->call ($ method , $ uri );
162161 }
163-
162+
164163 // check for success
165164 if ($ object ->success == true ) {
166165 // Decode JSON body
@@ -186,7 +185,7 @@ public function __call($name, $arguments)
186185
187186 }
188187
189- break ;
188+ break ;
190189 case 'xml ' :
191190
192191 switch ($ method ) {
@@ -506,7 +505,15 @@ protected function processJsonMappings($arguments, $api): array
506505 $ json = str_ireplace ('{ ' . $ key . '} ' , array_get ($ arguments [0 ], $ value , null ), $ json );
507506 }
508507 }
509- return json_decode ($ json , true );
508+ $ mapping = json_decode ($ json , true );
509+ if ($ mapping == null ) {
510+ Log::error ("ApiBuilder->processJsonMappings() - Error while decoding string " , [
511+ 'json ' => $ json ,
512+ 'arguments ' => $ arguments ,
513+ 'api ' => $ api ,
514+ ]);
515+ }
516+ return $ mapping ;
510517 }
511518
512519 /**
@@ -545,7 +552,7 @@ protected function processFormParamsMappings($arguments, $api): array
545552 $ json = str_ireplace ('{ ' . $ key . '} ' , array_get ($ arguments [0 ], $ value , null ), $ json );
546553 }
547554 }
548- return json_decode ($ json ,true );
555+ return json_decode ($ json , true );
549556 }
550557
551558 /**
0 commit comments