1

I've created a new data schema (using shoutem schema command) that looks like this:

{
  "name": "auditlog",
  "title": "AuditLog",
  "titleProperty": "name",
  "type": "object",
  "properties": {
    "name": {
      "format": "single-line",
      "title": "Name",
      "type": "string",
      "displayPriority": 1
    },
    "type": {
      "title": "Type",
      "format": "single-line",
      "type": "string",
      "displayPriority": 2
    },
    "moreInfo": {
      "title": "More Info",
      "format": "object",
      "type": "object",
      "displayPriority": 3
    }
  }
}

I've connected it to admin pages like this:

    "adminPages": [
        {
          "page": "shoutem.cms.CmsPage",
          "title": "Audit Log",
          "parameters": {
            "schema": "@.AuditLog"
          }
        }
      ]

I tested adding a new item from the cms screen and it works perfectly.

Now I am trying to add a new item from react-native mobile app part using redux-io and create method like so:

const item = {
  type: ext('AuditLog'),
  attributes: {
    name: 'Test',
    type: 'get',
  },
};

const config = {
  schema: ext('AuditLog'),
  request: {
    headers: {
      'Content-Type': 'application/vnd.api+json',
      accept: 'application/vnd.api+json',
    },
  },
};

const createAction = create(config, item);
dispatch(createAction);

But when I try to do this, I get the following error:

{
   "message":"403 - undefined",
   "name":"ApiError",
   "response":{
      "errors":[
         {
            "code":"legacy_security_default",
            "status":"403",
            "title":"Forbidden."
         }
      ]
   }
}

Am I missing something that needs to be added to request?

  • I'm making a comment instead of a full answer because this is just my first glance at the matter. I would suggest adding an authorization header with `Bearer ` and using the token located under the `authorization` property in either `shoutem.application/app/buildConfig.json` or the one in the root of the app `AppName/config/buildConfig.json`. If this ends up being the answer, I'll make an answer instead of just a comment, for future users that bump into this. – Vladimir Vdović Jun 16 '20 at 13:45
  • @VladimirVdović now I get error 500: `{ code: "legacy_serverError_default", status: "500", title: "Internal server error." }` Without any additional explanation. – Slobodan Džakić Jun 16 '20 at 14:05
  • @VladimirVdović is there anything else I can try, maybe I am missing something else that is required in item or config objects? – Slobodan Džakić Jun 18 '20 at 09:09
  • Could you try completely removing the request property from your config? I believe `create` really only needs the schema name in this context. Also, the [schema name](https://github.com/shoutem/extensions/blob/master/shoutem.about/extension.json#L87) should match the one provided in your `extension.json` which I will assume is `AuditLog`. – Vladimir Vdović Jun 18 '20 at 13:20

0 Answers0