Title: REST API JSON not working
Last modified: September 7, 2020

---

# REST API JSON not working

 *  Resolved [catalin.oanca](https://wordpress.org/support/users/catalinoanca/)
 * (@catalinoanca)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/rest-api-json-not-working/)
 * I’m using [https://wordpress.org/plugins/rest-routes/](https://wordpress.org/plugins/rest-routes/)
   and with the help of it’s developer I was able to create a one-level array of
   same-structured objects as requested by wpdatatables. Screenshot: [http://prntscr.com/ud83ei](http://prntscr.com/ud83ei)
 * If I add the URL [https://domain.com/wp-json/portfolio/assets](https://domain.com/wp-json/portfolio/assets)
   which has the output in the screenshot above, I get the error: “Please provide
   a valid 2-dimensional array.”
 * But if I save the output above in a file called assets.json and I try to add 
   the URL [https://domain.com/assets.json](https://domain.com/assets.json) it works
   just fine.
 * Is this supposed to happen? Is there a way to make it work with the REST API?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [catalin.oanca](https://wordpress.org/support/users/catalinoanca/)
 * (@catalinoanca)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/rest-api-json-not-working/#post-13374674)
 * I must have been tired because I skipped on the rule number 1 of debugging: deactivate
   all other plugins to make sure there’s no conflict.
    In this case the REST API
   was restricted and wpdatatables couldn’t reach it.
 * As a feature request, it would’ve been nice to have better error reporting or
   at least a debug mode to find out why the JSON wasn’t accepted. The JSON was 
   fine, the problem was the plugin didn’t evaluate the JSON but instead the array
   below.
 * Array
    ( [code] => rest_cannot_access [message] => DRA: Only authenticated users
   can access the REST API. [data] => Array ( [status] => 401 )
 * )
 *  Plugin Author [wpDataTables](https://wordpress.org/support/users/wpdatatables/)
 * (@wpdatatables)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/rest-api-json-not-working/#post-13388139)
 * Hello there
 * Thank you for letting us know the issue is resolved. Also, thanks for the suggestion!
 * It will be forwarded to our development team, so they can include it in one of
   our next updates.
 * Best regards.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘REST API JSON not working’ is closed to new replies.

 * ![](https://ps.w.org/wpdatatables/assets/icon-128x128.gif?rev=3010404)
 * [wpDataTables - WordPress Data Table, Dynamic Tables & Table Charts Plugin](https://wordpress.org/plugins/wpdatatables/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpdatatables/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpdatatables/)
 * [Active Topics](https://wordpress.org/support/plugin/wpdatatables/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpdatatables/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpdatatables/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [json](https://wordpress.org/support/topic-tag/json/)
 * [rest](https://wordpress.org/support/topic-tag/rest/)

 * 2 replies
 * 2 participants
 * Last reply from: [wpDataTables](https://wordpress.org/support/users/wpdatatables/)
 * Last activity: [5 years, 7 months ago](https://wordpress.org/support/topic/rest-api-json-not-working/#post-13388139)
 * Status: resolved