1

I am developing a api using codeigniter for user signup and user update profile. I have image field in form. To create user i have used post method which works fine. But issue i am getting when i am updating user. I know that with put request we have to send urlencoded or json data. But what should i do to update image?

Should i make 2 request? One with normal url encoded data (PUT request) and one with post request (Update image).

In rest api development which is the significant way to deal with these type of request? can anyone help me?

chiku
  • 60
  • 6
  • To update an existing resource, perhaps your REST api could use the PATCH method. – Brian Minton Jan 16 '20 at 14:59
  • Thank you for your reply. Patch supports multipart form data? – chiku Jan 16 '20 at 15:25
  • Here's a question about that exact topic: https://stackoverflow.com/questions/54699108/doing-a-patch-with-a-file-and-some-fields-using-multipart-form-data (but it currently doesn't have an answer). So, I don't know. – Brian Minton Jan 16 '20 at 16:09
  • Ok I checked patche method but it doesn’t support multipart form data. My point is that if i want to update user’s data with image as well then should i use single post method call with all data or make 2 requests 1 with put method with data update and 1post method for image upload ? – chiku Jan 16 '20 at 17:11
  • https://stackoverflow.com/questions/9464935/php-multipart-form-data-put-request – Atural Jan 17 '20 at 12:38

1 Answers1

0

You can try Advance Rest API plug-ins or browser extension, or you can try postman software for testing api with multipart-formdata (images) enter image description here