Questions tagged [json]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
13
votes
2answers
17k views

How can I return actual JSON using Drupal?

I'd like to implement a simple AJAX function locally that allows me to autocomplete node titles of already existing nodes as the user types. To that end, I need the ability to have an API that I can ...
10
votes
5answers
6k views

Creating comments and nodes with Services 3.x and JSON

I'm having trouble getting services to recognize a POST to /comment.json. I have a similar issue with creating nodes as well. The following is the error I get: HTTP/1.1 406 Not Acceptable: Missing ...
9
votes
2answers
4k views

How do I consume JSON data via a hook_menu callback?

I'm trying to set up Tropo's WebAPI with a Drupal site, and I thought I'd just create a hook_menu() callback for example.com/tropo, then use the hook_menu callback I just created to consume the API ...
7
votes
1answer
6k views

Drupal 8 node serialization to JSON

I am trying to use \Drupal\node\Entity\Node::load($nid) to store a node object in a variable and pass the variable into drupal 8's serialization component or even symphony's serialization methods. All ...
7
votes
3answers
13k views

How to return JSON data using Drupal 7

card.module drupal_add_js('jQuery(document).ready(function () { currentRequest = $.ajax({ timeout:0, cache: false, url: pageUrl, dataType: "json", type: "GET", success: function(data){ ...
6
votes
4answers
20k views

How to receive JSON data in controller with Drupal 8?

I'm using AngularJS one of my module's settings page, so I have a javascript object in client side as a model. Could anyone help me please, how to catch this data in a controller if I send it as JSON ...
6
votes
4answers
8k views

Drupal 7 - How do I parse JSON data from a website and import them as Nodes and have them update hourly?

I have drupal 7 with the Feeds and FeedsJSONParser module installed, but I can't seem to figure out how to configure this to parse the feeds. I want to parse the following feeds into their own nodes: ...
6
votes
3answers
5k views

Setting Up Drupal 8 REST Post Request

I am having issues sending a POST request to create a node with Drupal 8 Core REST. Here are the steps I have went through several times. Note that these steps are in effort to produce a working ...
6
votes
3answers
8k views

Views generating JSON output

I want to pull a JSON file out of a view that has images. This is similar to the way views_datasource works in D6. I am not a drupal coder, but I would like to give this a try. but I am guessing ...
6
votes
3answers
723 views

Simple OAuth + JSONapi response when token is expired - Decoupled

We're using the 'Simple OAuth' and 'jsonapi' modules for the front end authentication in Angular of our decoupled Drupal project. We've noticed that when the user credentials are correct but the ...
6
votes
1answer
999 views

Change views exposed filter format

I am build a JSON export using a View in Drupal 8. Problem is that the parameters for retrieving the json doesn't seem to work as I would want. In my View I need use two exposed filter criteria to ...
5
votes
3answers
4k views

How do I correctly setup caching for my custom API routing?

I have custom module with some routes which return JSON, for instance terms of a vocabulary. routing.yml mymodule.terms: path: '/api/terms/{vid}' defaults: _controller: '\Drupal\mymodule\...
5
votes
3answers
5k views

Custom REST POST resource to accept JSON

I am trying to build simple search autocomplete POST endpoint, that accepts JSON and outputs JSON, but I am having problems getting Drupal 8 to just accept plain JSON. Currently I am getting a 404 ...
5
votes
1answer
797 views

How to change view REST export format

This is my settings in view. Data what I have is now in this format: [{"created":"1551709414","field_iot_integer":"43"}, {"created":"1551709404","field_iot_integer":"98"}, {"created":"1551709392","...
5
votes
1answer
2k views

How can I PUT a new file to a node using services 3 without overwriting the existing file?

Using Services 3 I have it working fine to add a file using endpoint/file {"uid":"1","filesize":"99999","filename":"whatever.bin","file":"BASE64_ENCODED_DATA"} and also to add a node with that file ...
4
votes
1answer
6k views

Drupal 8 convert json to Array

I´m getting data from web service in Drupal 8: $uri = "http://localhost:8888/drupal8/tipo_receta.json"; try { $response = \Drupal::httpClient()->get($uri, array('headers' => array('Accept' ...
4
votes
2answers
46k views

How to read JSON from external URL and display in a block?

I want to load some JSON data from an external URL and display it in a block. How do I go about that?
4
votes
3answers
7k views

Register User with Services (JSON) with Custom Fields

I am trying to register a new user on Drupal7 via services with JSON. Actually I am posting info from JAVA (android) with JSON format to the server with services module enabled. A sample successful ...
4
votes
3answers
5k views

Get the latitude and longitude from the user ip

I am trying to get the latitude and longitude from the user who connected to my website to draw or show his position on a map, but it showed him in the wrong postion. Is there any way to get the ...
4
votes
3answers
10k views

405 Method Not Allowed Error when making a JSON API request from a simple create-react-app

The following request is giving me a 405 Method not allowed when running from a simple create-react-app generated project from localhost:3000. I really need this app to run outside of the domain (...
4
votes
2answers
3k views

What hook can I use to modify Views Datasource JSON output?

I'm using Views and Views Datasource to generate a JSON feed for my site. I've got a Video field which has both a video and a thumbnail image. I want to include the url of the thumbnail image in my ...
4
votes
2answers
4k views

Drupal 7 services json node object

There seems to be a problem with the Services module of Drupal 7 when submitting nodes using the node create reosurce, for example I can create nodes just fine, even with custom fields, but the ...
4
votes
2answers
826 views

How to import taxonomy from Json format

I have taxonomy in Json file. I need import this file into Drupal into exist vocabulary.how can I import data from Json file to exist vocabulary?
4
votes
1answer
688 views

Request parser best practices for Services 3.x

When you create a service endpoint you can enable various request parsers (application/json, application/x-www-form-urlencoded, multipart/form-data...) How should I decide whether to send the request ...
3
votes
1answer
4k views

Getting views data as a REST service

I need a way to get the output of a view as a REST service in JSON format. I read about the RestfulWS and the Services modules, but I didn't find enough documentation. Are these straight forward, or ...
3
votes
2answers
2k views

Drupal 8 REST - How to export Drupal 8 Main navigation menu with REST service (JSON)

I have tried to GET main menu with rest path "/entity/menu/{menu}" but all I get in response JSON is a menu properties as uuid,language,id... without menu structure (links...). { "uuid": "93d5d0a9-...
3
votes
1answer
366 views

Is there advantage to using Drupal.settings, as opposed to directly passing json-encoded var to javascript function

Inside my custom views template, views-view-myview.tpl.php, I have a variable ("$myvar"), which I need to pass to a custom javascript function. Here is how I am currently doing it: A. json-encode $...
3
votes
3answers
2k views

How can I fetch the complete main navigation menu via JSON:API?

How can I fetch the complete main navigation menu via jsonapi? I've tried: curl --header 'Accept: application/vnd.api+json' https://cms.example.com/jsonapi/menu/menu/ and curl --header 'Accept: ...
3
votes
1answer
973 views

Services 3 Output alter hook

Are there any hooks to alter the Services modules output. For eg : If I get a result like this for a file object. { "fid": "132", "uri": "public:\/\/512dab4918036.jpg", "filename": "...
3
votes
1answer
455 views

REST export for nested lists of content

Ok here is my problem; I have a list of boats. Each boat have a list of engines that can be fitted to it. Engine is not in anyway coupled with boat as a particular engine can be mounted to any kind ...
3
votes
1answer
1k views

Converting JSON to select list options

I have an array that I have JSON decoded from a JSON object. Below is my array I am using for select options. The problem is each select options has a option group with a number (0-11). How can I ...
3
votes
2answers
3k views

Get Thumbnail Image URL for Video in Views

I've got a Video field and the Video Thumbnail is uploaded by the user. I've got a View which is generating JSON (with the views_datasource extension). I want to include the image url to the Video ...
3
votes
1answer
4k views

Create Json from a view

I'm trying to create a json from Views, using Views Datasource. The problem is that if I create a display "page", using Json as style, if I try to go to www.mysite.com/path/to/page the system doesn't ...
3
votes
2answers
2k views

Format of the JSON returned by the Services module

I have a big doubt about the JSON format the Services module (for Drupal 6) generates. When I view the XML, all is OK. <result is_array="true"> <item> <nid>9</nid> <...
3
votes
1answer
4k views

How to return JSONP from a menu callback

I can create JSON output using a menu hook using the drupal_json_output callback. Example: $items['page/%/json'] = array( 'access callback' => TRUE, 'page callback' => '...
3
votes
1answer
1k views

REST for nested paragraphs

I need to create a rest service that delivers the current data: getNode(nid) -> all node fields -> if field is entity reference (like file, human readable urls) -> include subfields -> ...
3
votes
1answer
2k views

How do you upload an image via jsonapi?

The documentation is vague: https://www.drupal.org/docs/8/modules/json-api/working-with-files-post I am trying to upload an image following the sample code given for uploading a "document" on above ...
3
votes
1answer
587 views

How to get location (longitude and latitude) from json data show on map?

I am using Openlayers module to have a map. In my json, it has longitude and latitude field. I want to get them to show on map so that user can see the location with the marker. Is there any way to ...
3
votes
1answer
1k views

How to add data to Drupal.settings without drupal_add_js

Is there any way to add some variables to Drupal.settings without drupal_add_js (with setting argument). I'm creating a site that has a custom ctools popup style but I'm not feeling good with ...
3
votes
1answer
2k views

Match JSON POST data with custom node fields

Is there a fool-proof method to generate a correctly formatted JSON data object to be received by a create node resource given by a REST server, defined with Services in Drupal 7? I have setup a REST ...
3
votes
1answer
201 views

Using OAuth2 on non-REST endpoints

I have a custom module which includes a ControllerBase. The controller has a content() function that returns a JsonResponse(). The code for this function returns a complete list of a certain entity ...
3
votes
1answer
898 views

Filter by taxonomy parent using Json api

In drupal 8.5 I have a taxonomy term list like this: Term A (12 items) Term 1 (3 items) Term 2 (8 items) Term 3 (1 items) Term B (3 items) Term 4 (1 items) Term 5 (2 items) I want to use ...
3
votes
1answer
290 views

what json structure does simple oauth expect?

Drupal 8. I'm new with simple Oauth. I had manage to do this: But I want to do it with the Raw format, cuz my frontend is in Angular, so I will send a Json to Drupal. This is my first try: { ...
3
votes
1answer
2k views

Views JSON entity reference fields [closed]

I have a page content type with fields Title, Body and Blocks field collection with fields Title and URL. It might be field collection, paragraphs or entity reference, it doesn't matter because all ...
3
votes
2answers
1k views

Why does trying to POST a node from Android result in “HTTP/1.1 415 Unsupported Media Type”? [closed]

I used the following code to post some data to my site. I tested the site with Postman using the same data and it works properly, but when running the following code on Android Studio, response....
3
votes
0answers
62 views

How do I get back JSON value using entityform?

I am using drupal 7 entityform in this case, as i want CRUD functionality with the form. Can anyone tell me how should i configure my services. As of now i have configured it manually, selected the ...
3
votes
1answer
498 views

drupal_http_request returning Invalid JSON primitive:

I am developing a module for Drupal 7 that has t make a call to a remote API. I am using drupal_http_build_query and drupal_http_request and finally drupal_json_decode to decode the output. My code ...
3
votes
2answers
536 views

Strip HTML tags from Field Collections in Services Views

I'm trying to strip the HTML tags from a JSON response I generated using Services Views, but I'm not having any luck so far. I have a content type with a Field Collections field in it that is ...
3
votes
1answer
434 views

Templating JSON

Is there a Drupal way to template the results of ajax query that returns JSON. The JSON is is being returned to some php module code. If there is not a Drupal way I was thinking of using something ...
3
votes
1answer
1k views

Drupal Services send JSON from Android [closed]

My Android developer and I are having trouble posting the JSON data to our drupal services. I am not familiar with Java but I have used Httpposter to post my JSON data to create nodes on my site. We ...

1
2 3 4 5
7