What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Another question I have: I'm trying to build the Glue API right now, but I'm struggling a little wit

U01DE320SN6
U01DE320SN6 Posts: 37 🧑🏻‍🚀 - Cadet

Another question I have:
I'm trying to build the Glue API right now, but I'm struggling a little with post requests. According to documentation, I made the transfer object:

<?xml version="1.0"?>
<transfers xmlns="spryker:transfer-01"
           xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>"
           xsi:schemaLocation="spryker:transfer-01 <http://static.spryker.com/transfer-01.xsd>">

    <transfer name="NewsApiTransfer">
        <property name="id" type="integer" />
        <property name="wordpressId" type="integer" />
    </transfer>

</transfers>

And mapped it to the resource plugin:

public function getResourceAttributesClassName(): string
    {
        return NewsApiTransfer::class;
    }

I've made the controller and method:

public function postAction(NewsApiTransfer $transfer)
    {
        dd($transfer);
    }

Yet, while trying to call this API, I keep getting 400: Post data is invalid:

Comments

  • Eugenia Poidenko
    Eugenia Poidenko Sprykee Posts: 145 🧑🏻‍🚀 - Cadet

    Hi!

    Try

    {
        "data": {
            "type": "news",
            "attributes": {
                "id": 1,
                "wordpressId": 1
            }
        }
    }
    
  • Eugenia Poidenko
    Eugenia Poidenko Sprykee Posts: 145 🧑🏻‍🚀 - Cadet

    the transfer describes the attributes part only, the rest (data, data.type and optionally data.id) is the JSONAPI structure that should be present in all the requests and responses

  • U01DE320SN6
    U01DE320SN6 Posts: 37 🧑🏻‍🚀 - Cadet

    Thank you Eugenia, this way it works just fine