# JSON error yet it's a valid json?

**URL:** <https://devforum.zoom.us/t/json-error-yet-its-a-valid-json/99794>\
**Category:** API and Webhooks\
**Tags:** phone, api\
**Created:** [December 8, 2023, 9:49am UTC](https://devforum.zoom.us/t/json-error-yet-its-a-valid-json/99794 "2023-12-08T09:49:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![direktuser](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/direktuser/32/54668_2.png) [@direktuser](https://devforum.zoom.us/u/direktuser)\
**Post date:** [December 8, 2023, 9:49am UTC](https://devforum.zoom.us/t/json-error-yet-its-a-valid-json/99794/1 "2023-12-08T09:49:21Z")

</div>

### Format Your New Topic as Follows:

**API Endpoint(s) and/or Zoom API Event(s)**

```http
POST https://api.zoom.us/v2/phone/external_contacts

```

**Description**  
I fiddle arround an allegedly JSON error which turns out to be just some wired behavior of the Zoom API. And yes, I am 100% sure it’s not some parsing error etc. as you will see below.

**Error Message**

```json
{
    "code": 300,
    "message": "Request Body should be a valid JSON object."
}

```

**Code**

```php
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
]);

```

So far, so good. Everything seems fine. After the first code-checks I also sent the request to another endpoint where I logged everything I fetched:

- Header: OK
  - Content-Type: OK

- Content: OK
  - Content is sent: YES
  - Content is JSON: YES
  - Content JSON can be decoded: YES
  - Decoded JSON is valid / usable: YES

After that, I played arround even more. And the fun begins.

Example contact I send to Zoom API: _(from the documentation)_

```json
{
  "description": "External contact Johnson",
  "email": "example@example.com",
  "extension_number": "101014",
  "id": "external_contact_01",
  "name": "Johnson",
  "phone_numbers": [
    "+12058945656"
  ],
  "routing_path": "PSTN",
  "auto_call_recorded": true
}

```

**How To Reproduce my Error**  
Aside the given error above, if I send the demo contact to the API, I get the at this point expected:

```json
{
    "code": 300,
    "message": "Request Body should be a valid JSON object."
}

```

What is really strange is what happens if I send the very same JSON object without "phone\_numbers"key-value pair:

```json
{
    "code": 400,
    "message": "Phone number cannot be blank."
}

```

Which means, Zoom is pretty well able to read / validate my JSON object, they just plain refuse to do so for some reason. Since I send 1:1 the demo-account they supplied in their documentation, I unable to guess whats the problem with this contact data.

Does anyone have any idea / trick what we can check / enable / update / modify to get something going. It’s pretty nuts the JSON-validation seemingly is also thrown aside JSON errors.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [December 11, 2024, 1:26am UTC](https://devforum.zoom.us/t/json-error-yet-its-a-valid-json/99794/2 "2024-12-11T01:26:10Z")

</div>

This topic was automatically closed 368 days after the last reply. New replies are no longer allowed.
