jaybo Posted September 16, 2021 Share Posted September 16, 2021 (edited) I am sending an API call to GWN API network/create endpoint and my payload is an array as below; $body_data = array( 'networkName' => 'BFCMA_55_ChaitAdam', 'country' => 'US', 'timezone' => 'America/New_York', 'networkAdministrators' => array( '13497', '13788' ), 'cloneNetworkId' => 29652 ); When I echo $body_data the output is; {“networkName”:“BBC_55”,“country”:“US”,“timezone”:“America\/New_York”,“networkAdministrators”:[“12345”,“13456”],“cloneNetworkId”:02345} I need the timezone to be “America/New_York” NOT “America\/New_York” as is outputted. How do I do that? Edited September 16, 2021 by jaybo Quote Link to comment https://forums.phpfreaks.com/topic/313748-my-php-code-outputs-as/ Share on other sites More sharing options...
requinix Posted September 16, 2021 Share Posted September 16, 2021 Is it actually causing you problems? I mean real problems? Because JSON allows for escaped slashes like that. Quote Link to comment https://forums.phpfreaks.com/topic/313748-my-php-code-outputs-as/#findComment-1589978 Share on other sites More sharing options...
Solution jaybo Posted September 16, 2021 Author Solution Share Posted September 16, 2021 Yes it was. Found an answer that worked - I added JSON_UNESCAPED_SLASHES when encoding the data. $body = json_encode($body_data, JSON_UNESCAPED_SLASHES); Also unquoted the networkAdministrators array values and the call was successful. Quote Link to comment https://forums.phpfreaks.com/topic/313748-my-php-code-outputs-as/#findComment-1589981 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.