I'm sending form data to Django Rest Framework View like this for all serialized data of a nested object named security:
------WebKitFormBoundaryAOygB8mq3Oo5I7ii
Content-Disposition: form-data; name="security[title]"
P
and it fails with 400 error saying that the field security is required.
When I'm using the DRF's web view and fill the form there, POST it I'm seeing that the notation is like this
------WebKitFormBoundaryAOygB8mq3Oo5I7ii
Content-Disposition: form-data; name="security.title"
P
As I'm using angular with ng-upload and its Upload lib (coffee):
Upload.upload(
url: '/services/rest/.../'+id+'/upload'
data:
$scope.object)
to send the form data.
Question which is correct? the dotted or [] notation? Which side to fix?
found it: Upload lib can be configured by objectKey: '.k'
details:
*data: {key: file, otherInfo: uploadInfo},
/*
This is to accommodate server implementations expecting nested data object keys in .key or [key] format.
Example: data: {rec: {name: 'N', pic: file}} sent as: rec[name] -> N, rec[pic] -> file
data: {rec: {name: 'N', pic: file}, objectKey: '.k'} sent as: rec.name -> N, rec.pic -> file */
objectKey: '[k]' or '.k' // default is '[k]'
You Should try make your key as security.title in FormData
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With