Can anyone help decoding the right JSON for JSONAPI?

Created on 2 February 2023, over 1 year ago
Updated 14 July 2023, 11 months ago

Problem/Motivation

Hi -- The basic documentation is pretty good for POSTing some JSON to create a new piece of content, but I need to figure out a bit more detail. I can figure out the format for the body section from the documentation but the format for some of the other fields are confusing me. I don't know which parts to include in the JSON for, say, the Url or Link field. Or the Geofield.

Any hints on how to understand this? I'm happy to write the documentation if I can figure out what to put in the JSON packets.

💬 Support request
Status

Closed: outdated

Version

10.0 ✨

Component
JSON API  →

Last updated 2 days ago

Created by

🇺🇸United States bogdog400

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @bogdog400
  • 🇺🇸United States cilefen
  • 🇺🇸United States bogdog400

    Hi--

    I was able to answer my problem by doing a new installation with Drupal 9.5.3. Perhaps version 10.0.3 was preventing my GET commands from working.

    Another help was finding the JSONAPI Explorer which made it a bit easier to dig into the JSON.

    https://www.drupal.org/project/jsonapi_explorer →

    BTW, my biggest hassle was figuring out that cross origin scripting was blocking the JSON calls from the explorer. When I turned that off, I was able to get it to work.

    Thanks very much. I'll leave this as a pointer to others.

  • Assigned to rifas-ali-pbi
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India rifas-ali-pbi Kerala

    Hi its actually quite easy to understand. The idea is to first give a GET request. Then you will get the JSON data. Same structure is used to send the POST data too.

    Body of your desired fields will look like following, I have added geolocation field, link field and an example body.

    {
        "data": {
            "type": "node--article",
            "attributes": {
                "title": "Rifas test post from postman POST",
                "body": {
                    "value": "<p>description</p>\r\n"
                },
                "field_location": {
                    "lat": 90,
                    "lng": 40
                },
                "field_link": {
                    "uri": "https://www.google.com/",
                    "title": "Link Test here",
                    "options": []
                }
            }
        }
    }
  • Issue was unassigned.
  • 🇺🇸United States bogdog400

    Yes. That's how I've solved it in the past. But for some reason my installation of 10.0.3 doesn't respond correctly to GET requests. So I ended up building a test version with 9.5.3 and that's worked.

  • Status changed to RTBC over 1 year ago
  • Status changed to Postponed: needs info over 1 year ago
  • 🇺🇸United States cilefen

    There is not a code diff to review.

  • Status changed to Closed: outdated 11 months ago
  • 🇺🇸United States cilefen
Production build 0.69.0 2024