New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PATCH user/custom not working? #156

Closed
luisbatista opened this Issue Jul 27, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@luisbatista

luisbatista commented Jul 27, 2017

Hello,

I try to update “user_custom” records.

I go to “API DOCS” menu option, and in the:
PATCH /user/custom
with the payload:

{ "resource": [
    {
      "id": 279,
      "user_id": 1,
      "name": "nif",
      "value": "000111000"
    }
  ]
}

I verify the table in the database and the record exists, the intention is to change the “value: ‘000000000’” to the new value: “value: ‘000111000’”.

When I call the request (in API DOCS), get this response:

**Request URL**
http://developer.mygreatsite.com/api/v2/user/custom
**Response Body**
{
  "error": {
    "code": 1000,
    "context": {
      "error": [
        0
      ],
      "resource": [
        {
          "code": 404,
          "context": null,
          "message": "Record with identifier '279' not found.",
          "status_code": 404
        }
      ]
    },
    "message": "Batch Error: Not all requested records could be updated.",
    "status_code": 500
  }
}

This is a DF issue or other problem?!
Any help?!

Best regards,
LB

@todda48

This comment has been minimized.

Show comment
Hide comment
@todda48

todda48 Jul 27, 2017

Contributor

Hi LB,

user/custom is for storing name-value pairs for the current user. There is no 'id' field exposed via the API. Use POST to create or update a value as described here.

http://wiki.dreamfactory.com/DreamFactory/Tutorials/Managing_user_custom_data

POST /user/custom
{ "resource": [
{
"name": "nif",
"value": {"field1": "foo", "field2": "bar"}
}
]
}

Hope this helps. If you're looking for free support you might do better posting in the forums.

http://community.dreamfactory.com/

Contributor

todda48 commented Jul 27, 2017

Hi LB,

user/custom is for storing name-value pairs for the current user. There is no 'id' field exposed via the API. Use POST to create or update a value as described here.

http://wiki.dreamfactory.com/DreamFactory/Tutorials/Managing_user_custom_data

POST /user/custom
{ "resource": [
{
"name": "nif",
"value": {"field1": "foo", "field2": "bar"}
}
]
}

Hope this helps. If you're looking for free support you might do better posting in the forums.

http://community.dreamfactory.com/

@luisbatista

This comment has been minimized.

Show comment
Hide comment
@luisbatista

luisbatista Jul 27, 2017

Thanks a lot @todda48 ,

I post in the forum, but no lucky with an answer.

To finish, if I want to change a specific item for the logged user, because I have in the "user_custom" same pair/value to all registered users, when I need to change a value for a specific user I need to know where to change! How made this?

In the API DOCS, I see the PATCH user/custom/{id} is this endpoint or if I use the above (POST user/custom/) get the same result ?

Best regards,
LB

luisbatista commented Jul 27, 2017

Thanks a lot @todda48 ,

I post in the forum, but no lucky with an answer.

To finish, if I want to change a specific item for the logged user, because I have in the "user_custom" same pair/value to all registered users, when I need to change a value for a specific user I need to know where to change! How made this?

In the API DOCS, I see the PATCH user/custom/{id} is this endpoint or if I use the above (POST user/custom/) get the same result ?

Best regards,
LB

@todda48

This comment has been minimized.

Show comment
Hide comment
@todda48

todda48 Jul 27, 2017

Contributor

The API Docs are a little confusing for /user/custom. {id} is actually the name in this case. We'll try to get that cleaned up. But it still works. You can use PUT or PATCH to change the value, but you need the name in the URL like this.

PUT /user/custom/nif
{"value": {"field1": "foo", "field2": "bar"}}

PATCH /user/custom/nif
{"value": {"field1": "foo", "field2": "bar"}}

Or you can do POST again just like when you created it. This requires a resource array.

POST /user/custom
{
  "resource": [
    {
      "name": "nif",
      "value": {
        "field1": "foo",
        "field2": "bar"
      }
    }
  ]
}

Keep in mind this only changes the value for the CURRENT user. There is currently no way for user A to change the value for user B via the API.

Contributor

todda48 commented Jul 27, 2017

The API Docs are a little confusing for /user/custom. {id} is actually the name in this case. We'll try to get that cleaned up. But it still works. You can use PUT or PATCH to change the value, but you need the name in the URL like this.

PUT /user/custom/nif
{"value": {"field1": "foo", "field2": "bar"}}

PATCH /user/custom/nif
{"value": {"field1": "foo", "field2": "bar"}}

Or you can do POST again just like when you created it. This requires a resource array.

POST /user/custom
{
  "resource": [
    {
      "name": "nif",
      "value": {
        "field1": "foo",
        "field2": "bar"
      }
    }
  ]
}

Keep in mind this only changes the value for the CURRENT user. There is currently no way for user A to change the value for user B via the API.

@luisbatista

This comment has been minimized.

Show comment
Hide comment
@luisbatista

luisbatista Jul 27, 2017

Thanks again @todda48 for your great help.
Yes, the intention is to change the value for the current user :)

luisbatista commented Jul 27, 2017

Thanks again @todda48 for your great help.
Yes, the intention is to change the value for the current user :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment