problem in uploading files using jsonapi
chihada opened this issue · 1 comments
I am using Lightning 8.x-3.100 as backend, and attempting to upload files using jsonapi, I followed the guide comes in Working with files (POST) but I got the following response
{ "errors": [ { "title": "Internal Server Error", "status": 500, "detail": "Field data is unknown.", "links": { "info": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1" }, "code": 0 } ] }
the request:
curl --request POST \ --url http://localhost/Lightning/docroot/jsonapi/file/document \ --header 'Accept: application/vnd.api+json' \ --header 'Content-Type: application/vnd.api+json' \ --body'{ "data": { "type": "file--document", "attributes": { "data": "SGV5LCBpdCB3b3JrcyE=", "uri": "public://filename.txt" } } }
in the dblog I got the following message:
InvalidArgumentException: Field data is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 580 of C:\wamp64\www\Lightning\docroot\core\lib\Drupal\Core\Entity\ContentEntityBase.php).
by searching in jsonapi issues i found the same problem in #2946746: Field data is unknown
I applied the patch 2883086-54-combined.patch coming from #2883086: Port RequestHandler + ResourceResponse(Interface) improvements from REST module to JSON API but the problem did not solved
This seems like a problem with JSON API, and not something we can fix from here. I would suggest working with JSON API's maintainers in https://www.drupal.org/project/jsonapi/issues/2946746. In the meantime, I'm closing this issue.