<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Matheus Cardoso</title>
    <description>The latest articles on Forem by Matheus Cardoso (@matheuscas).</description>
    <link>https://forem.com/matheuscas</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F170198%2F976fe7c9-cb65-49c5-bfad-4a8bf214f3ec.png</url>
      <title>Forem: Matheus Cardoso</title>
      <link>https://forem.com/matheuscas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/matheuscas"/>
    <language>en</language>
    <item>
      <title>Adding SASS/Scss to your Vuejs project (and micro frameworks pains)</title>
      <dc:creator>Matheus Cardoso</dc:creator>
      <pubDate>Tue, 07 Jul 2020 16:39:15 +0000</pubDate>
      <link>https://forem.com/matheuscas/adding-sass-scss-to-your-vuejs-project-and-micro-frameworks-pains-4j5g</link>
      <guid>https://forem.com/matheuscas/adding-sass-scss-to-your-vuejs-project-and-micro-frameworks-pains-4j5g</guid>
      <description>&lt;p&gt;&lt;em&gt;Se você não ler em Inglês, esse mesmo artigo está escrito em português brasileiro, &lt;a href="https://dev.to/matheuscas/adicionando-sass-scss-ao-seu-projeto-vuejs-e-dores-de-micro-frameworks-3dp2"&gt;aqui&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This will be quick. Here's my &lt;code&gt;devDependencies&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"devDependencies": {
    "@vue/cli-plugin-babel": "^3.0.0-rc.12",
    "@vue/cli-plugin-eslint": "^3.0.0-rc.12",
    "@vue/cli-service": "^3.0.0-rc.12",
    "vue-template-compiler": "^2.5.17"
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'm telling you this because you may have using Vue CLI v4 or any other version that has this issue already solved. To use SASS/Scss in your template like this &lt;code&gt;&amp;lt;style lang="scss"&amp;gt;&amp;lt;/style&amp;gt;&lt;/code&gt; your &lt;code&gt;devDependencies&lt;/code&gt; will become&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"devDependencies": {
    "@vue/cli-plugin-babel": "^3.0.0-rc.12",
    "@vue/cli-plugin-eslint": "^3.0.0-rc.12",
    "@vue/cli-service": "^3.0.0-rc.12",
    "fibers": "^5.0.0",
    "node-sass": "^4.14.1",
    "sass": "^1.26.9",
    "sass-loader": "7.1.0",
    "style-loader": "^1.2.1",
    "vue-template-compiler": "^2.5.17"
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pay attention to &lt;code&gt;"sass-loader": "7.1.0",&lt;/code&gt;. This is the main key to make this works, because it seems that there's compatibility issues between Vue CLI 3 and &lt;code&gt;sass-loader&lt;/code&gt; recent versions. Oh, and also you must add to your &lt;code&gt;vue.config.js&lt;/code&gt; this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;configureWebpack: {
      module: {
        rules: [
          {
            test: /\.s(c|a)ss$/,
            use: [
              'vue-style-loader',
              'css-loader',
              {
                loader: 'sass-loader',
                // Requires sass-loader@^7.0.0
                options: {
                  implementation: require('sass'),
                  fiber: require('fibers'),
                  indentedSyntax: true // optional
                },
              },
            ],
          },
        ],
      },
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Credits to this guy that helped me a lot: &lt;a href="https://stackoverflow.com/a/47898293/2631087"&gt;https://stackoverflow.com/a/47898293/2631087&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It should work&lt;/strong&gt;, otherwise comment bellow. And also I think that there's should be a more elegant way to solve this - I just didn't find yet 😅. &lt;/p&gt;

&lt;h3&gt;
  
  
  Now, the following won't be that quick.
&lt;/h3&gt;

&lt;p&gt;I'm an Angular guy. Real fan and developer since when it was AngularJS. And I know that even more nowadays Angular is pretty (damn) verbose, huge compared to Vuejs (React, Svelte) and can be real tricky some times due to Zonejs and other "magics". BUT...It works! It just works! &lt;/p&gt;

&lt;p&gt;I have never bother myself in use or not CSS or SASS except to switch a simple option in CLI. And even more, I have never spent an hour just trying to find the solution for this kind of issue 🤯. Which led me to write this post. &lt;br&gt;
I don't need axios, other example, because Angular already have HTTP built-in and so many other &lt;strong&gt;choices&lt;/strong&gt; already made that I'm, in general, most comfortable with (Emberjs folks understand that feeling, I think). &lt;/p&gt;

&lt;p&gt;This is not a letter against Vuejs or any other lib or "micro framework", but a letter to whom is switching worlds (like me) or who is starting now and have to choose among Angular, Vuejs, Emberjs, React or any other FW/lib. &lt;/p&gt;

&lt;p&gt;Ps.: Despite of many things, &lt;strong&gt;I'm really enjoying Vuejs&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>vue</category>
      <category>saas</category>
    </item>
    <item>
      <title>Adicionando SASS/Scss ao seu projeto Vuejs (e dores de micro-frameworks)</title>
      <dc:creator>Matheus Cardoso</dc:creator>
      <pubDate>Tue, 07 Jul 2020 16:38:31 +0000</pubDate>
      <link>https://forem.com/matheuscas/adicionando-sass-scss-ao-seu-projeto-vuejs-e-dores-de-micro-frameworks-3dp2</link>
      <guid>https://forem.com/matheuscas/adicionando-sass-scss-ao-seu-projeto-vuejs-e-dores-de-micro-frameworks-3dp2</guid>
      <description>&lt;p&gt;&lt;em&gt;If you came here and don't read brazillian portuguese, take this reading in english &lt;a href="https://dev.to/matheuscas/adding-sass-scss-to-your-vuejs-project-and-micro-frameworks-pains-4j5g"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Isso será rápido. Aqui estão minhas &lt;code&gt;devDependencies&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"devDependencies": {
    "@vue/cli-plugin-babel": "^3.0.0-rc.12",
    "@vue/cli-plugin-eslint": "^3.0.0-rc.12",
    "@vue/cli-service": "^3.0.0-rc.12",
    "vue-template-compiler": "^2.5.17"
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Estou lhe dizendo isso porque você pode estar usando o Vue CLI v4 ou qualquer outra versão que já tenha esse problema resolvido. Para usar o SASS/Scss em seu  como este &lt;code&gt;&amp;lt;style lang ="scss"&amp;gt;&amp;lt;/style&amp;gt;&lt;/code&gt;, seu &lt;code&gt;devDependencies&lt;/code&gt; se tornará:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"devDependencies": {
    "@vue/cli-plugin-babel": "^3.0.0-rc.12",
    "@vue/cli-plugin-eslint": "^3.0.0-rc.12",
    "@vue/cli-service": "^3.0.0-rc.12",
    "fibers": "^5.0.0",
    "node-sass": "^4.14.1",
    "sass": "^1.26.9",
    "sass-loader": "7.1.0",
    "style-loader": "^1.2.1",
    "vue-template-compiler": "^2.5.17"
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Preste atenção ao &lt;code&gt;"sass-loader ":" 7.1.0",&lt;/code&gt;. Esta é a chave principal para fazer isso funcionar, porque parece que há problemas de compatibilidade entre o Vue CLI 3 e as versões recentes do &lt;code&gt;sass-loader&lt;/code&gt;. Ah, e você também deve adicionar ao seu &lt;code&gt;vue.config.js&lt;/code&gt; o seguinte:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;configureWebpack: {
      module: {
        rules: [
          {
            test: /\.s(c|a)ss$/,
            use: [
              'vue-style-loader',
              'css-loader',
              {
                loader: 'sass-loader',
                // Requires sass-loader@^7.0.0
                options: {
                  implementation: require('sass'),
                  fiber: require('fibers'),
                  indentedSyntax: true // optional
                },
              },
            ],
          },
        ],
      },
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Créditos a esse cara que me ajudou muito: &lt;a href="https://stackoverflow.com/a/47898293/2631087"&gt;https://stackoverflow.com/a/47898293/2631087&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deve funcionar&lt;/strong&gt;, caso contrário, comente abaixo. E também acho que deve haver uma maneira mais elegante de resolver isso - eu só não encontrei ainda 😅.&lt;/p&gt;

&lt;h3&gt;
  
  
  Agora, o seguinte texto não será tão rápido.
&lt;/h3&gt;

&lt;p&gt;Eu sou um cara angular. Fã e desenvolvedor desde quando era o AngularJS. E eu sei que hoje em dia, ainda mais, o Angular é bem verboso, enorme comparado ao Vuejs (React, Svelte) e pode ser bem complicado algumas vezes devido ao Zonejs e outras "mágicas". MAS ... Funciona! Ele simplesmente funciona!&lt;/p&gt;

&lt;p&gt;Eu nunca precisei me incomodar em usar ou não CSS ou SASS, e se eu quisesse, bastava mudao uma opção simples na CLI. E ainda mais, &lt;strong&gt;nunca passei uma hora inteira tentando encontrar a solução para esse tipo de problema&lt;/strong&gt; 🤯. Que foi que gerou esse post. &lt;br&gt;
Eu não preciso do axios, outro exemplo, porque o Angular já tem HTTP embutido e tantas outras &lt;strong&gt;escolhas&lt;/strong&gt; que eles já fizeram que eu, em geral, me sinto confortável (o pessoal do Emberjs entende esse sentimento, eu acho) .&lt;/p&gt;

&lt;p&gt;Esta não é uma carta contra o Vuejs ou qualquer outra lib ou "micro framework", mas uma carta para quem está mudando de mundo (como eu) ou que está começando agora e precisa escolher entre Angular, Vuejs, Emberjs, React ou qualquer outro FW/lib.&lt;/p&gt;

&lt;p&gt;Ps .: Apesar de muitas coisas, &lt;strong&gt;estou gostando muito do Vuejs&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>vue</category>
      <category>sass</category>
    </item>
    <item>
      <title>Dica rápida: POST para JSON:API</title>
      <dc:creator>Matheus Cardoso</dc:creator>
      <pubDate>Sun, 07 Jun 2020 16:22:07 +0000</pubDate>
      <link>https://forem.com/matheuscas/dica-rapida-post-para-json-api-25ni</link>
      <guid>https://forem.com/matheuscas/dica-rapida-post-para-json-api-25ni</guid>
      <description>&lt;p&gt;&lt;em&gt;If you arrived here and do not speak/read/write in native Portuguese/Brazilian Portuguese or do not prefer to read in this language, this same article is written in English &lt;a href="https://dev.to/matheuscas/quick-tip-posting-to-json-apis-2ngk"&gt;here&lt;/a&gt;&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;Esta é uma dica rápida para iniciantes em &lt;a href="https://jsonapi.org"&gt;JSON: APIs&lt;/a&gt;. Se você acha que é apenas JSON, pense novamente. É JSON e "mais algumas" definições. Aqui estão algumas coisas que eu não sabia, subestimando as especificações, e quebrei minha cabeça.&lt;/p&gt;

&lt;p&gt;Primeiro, o &lt;code&gt;Content-Type&lt;/code&gt; não é &lt;code&gt;application/json&lt;/code&gt;. O tipo correto é &lt;a href="https://jsonapi.org/#mime-types"&gt;application/vnd.api+json&lt;/a&gt;. Caso contrário, o servidor responderá com &lt;code&gt;415 Unsupported Media Type&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Segundo, seu &lt;em&gt;payload&lt;/em&gt; *&lt;em&gt;para fazer um POST deve *&lt;/em&gt; conter &lt;code&gt;data&lt;/code&gt; (conhecido como "dados primários") e ** deve ** ter pelo menos o seguinte formato:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"meu 'segredo' estava aqui"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"attributes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Se você esquecer de colocar &lt;code&gt;data&lt;/code&gt;, receberá o seguinte erro:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="s"&gt;"errors"&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="s"&gt;"detail"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"Received document does not contain primary data"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="s"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;
            &lt;span class="s"&gt;"pointer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"/data"&lt;/span&gt;
         &lt;span class="p"&gt;},&lt;/span&gt;
         &lt;span class="s"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"400"&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Você só precisa adicionar &lt;code&gt;data&lt;/code&gt; e colocar seu &lt;em&gt;payload&lt;/em&gt; em&lt;code&gt;atributos&lt;/code&gt;. Depois disso, se você esquecer o &lt;code&gt;type&lt;/code&gt; ou defini-lo como &lt;code&gt;None&lt;/code&gt;, porque estamos fazendo um &lt;strong&gt;POST&lt;/strong&gt;, você receberá o seguinte erro (ou algo semelhante):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="s"&gt;"errors"&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="s"&gt;"detail"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"The resource object's type (None) is not the type that constitute the collection represented by the endpoint (&amp;lt;O_NOME_DO_ENDPOINT&amp;gt;)."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="s"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;
            &lt;span class="s"&gt;"pointer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"/data"&lt;/span&gt;
         &lt;span class="p"&gt;},&lt;/span&gt;
         &lt;span class="s"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"409"&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;E o erro acima foi o que tomou minha energia e me fez escrever esse post. Demorei um pouco para descobrir, apesar da mensagem, qual foi o erro, mas pode ser diferente em outra situação/framework/estrutura, eu acho. Eis aqui a minha situação, usando Django + DRF + JSON:API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;rest_framework.decorators&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;api_view&lt;/span&gt;

&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;api_view&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;my_api_post_endoint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A partir do endpoint acima, usando &lt;code&gt;@api_view&lt;/code&gt; (e estou sendo bastante específico, porque não testei com ViewSets ou outros endpoints baseados em classe), apenas tive que definir o &lt;code&gt;type&lt;/code&gt; do &lt;em&gt;payload&lt;/em&gt; como o mesmo nome do endpoint. Como abaixo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="s"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;
      &lt;span class="s"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"my_api_post_endoint"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s"&gt;"attributes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"payload"&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;E foi isso! O POST estava passando e eu pude seguir em frente com o meu trabalho.&lt;/p&gt;

&lt;p&gt;Moral da história? Leia a p**** das especificações antes. 😅&lt;/p&gt;

</description>
      <category>api</category>
      <category>json</category>
      <category>python</category>
      <category>django</category>
    </item>
    <item>
      <title>Quick tip: posting to JSON:APIs</title>
      <dc:creator>Matheus Cardoso</dc:creator>
      <pubDate>Sun, 07 Jun 2020 16:21:41 +0000</pubDate>
      <link>https://forem.com/matheuscas/quick-tip-posting-to-json-apis-2ngk</link>
      <guid>https://forem.com/matheuscas/quick-tip-posting-to-json-apis-2ngk</guid>
      <description>&lt;p&gt;&lt;em&gt;Se você chegou aqui e não fala/ler/escreve nativamente inglês ou não prefere ler neste idioma, esse mesmo artigo está escrito em português do Brasil &lt;a href="https://dev.to/matheuscas/dica-rapida-post-para-json-api-25ni"&gt;aqui&lt;/a&gt;&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;This is a quick tip to newcomers to &lt;a href="https://jsonapi.org"&gt;JSON:APIs&lt;/a&gt;. If you think it's just JSON, think again. It's JSON and "some more" definitions. Here's some stuff that I didn't know, underestimating the specs, and cracked my head. &lt;/p&gt;

&lt;p&gt;First, the &lt;code&gt;Content-Type&lt;/code&gt; ain't &lt;code&gt;application/json.&lt;/code&gt;. The correct type is &lt;a href="https://jsonapi.org/#mime-types"&gt;application/vnd.api+json&lt;/a&gt;. Otherwise, the server will respond with &lt;code&gt;415 Unsupported Media Type&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Second, your payload &lt;strong&gt;to POST must&lt;/strong&gt; contain &lt;code&gt;data&lt;/code&gt; (called "primary data") and &lt;strong&gt;must&lt;/strong&gt; have at least the following format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"my final 'secret' was here"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"attributes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;your_payload&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you miss &lt;code&gt;data&lt;/code&gt; you'll get the following error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="s"&gt;"errors"&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="s"&gt;"detail"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"Received document does not contain primary data"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="s"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;
            &lt;span class="s"&gt;"pointer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"/data"&lt;/span&gt;
         &lt;span class="p"&gt;},&lt;/span&gt;
         &lt;span class="s"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"400"&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You just need to add &lt;code&gt;data&lt;/code&gt; and put your payload into &lt;code&gt;attributes&lt;/code&gt;. After that if you miss &lt;code&gt;type&lt;/code&gt; or setting as &lt;code&gt;None&lt;/code&gt;, because we're &lt;strong&gt;POSTING&lt;/strong&gt;, you will get the following error (or something similar):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="s"&gt;"errors"&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="s"&gt;"detail"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"The resource object's type (None) is not the type that constitute the collection represented by the endpoint (&amp;lt;ENDPOINT_NAME&amp;gt;)."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="s"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;
            &lt;span class="s"&gt;"pointer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"/data"&lt;/span&gt;
         &lt;span class="p"&gt;},&lt;/span&gt;
         &lt;span class="s"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"409"&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the above error was the one that took my energy and made me write down this post. It took me a while to figure out, despite of message, what was the error, however it can be different in other situation/framework/structure, I think. Here was my situation, using Django + DRF + JSON:API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;rest_framework.decorators&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;api_view&lt;/span&gt;

&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;api_view&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;my_api_post_endoint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Giving the above endpoint, using &lt;code&gt;@api_view&lt;/code&gt; (and I'm being pretty specific cuz I didn't tested with ViewSets or other class based endpoints) I just had to set the whole payload's &lt;code&gt;type&lt;/code&gt; as the same name of my endpoint. Like bellow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="s"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;
      &lt;span class="s"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"my_api_post_endoint"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s"&gt;"attributes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"payload"&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And..Done! The POST was passing and I could move on with my work. &lt;/p&gt;

&lt;p&gt;History's moral? Read the damn specs before. 😅&lt;/p&gt;

</description>
      <category>api</category>
      <category>json</category>
      <category>python</category>
      <category>django</category>
    </item>
  </channel>
</rss>
