I am using Services 7.x-3.3 and when I try to upload an image file (or any file) through the node resource attach_file target action, I get back "401 Unauthorized: Missing required argument field_name".

Here are some details:

  • I know my Services endpoint is working as a call to http://myhost/services/system/connect.json works fine (returns 200 OK)
  • My Services REST server has json and jsonp for the Response formatters and application/json, application/x-www-form-urlencoded, multipart/form-data for Response parsing.
  • I have enabled file resource: create, index, create_raw (Actions)
  • I have also enabled node resource: create, index, files (Relationships), and attach_file (Target actions)
  • I have a content type called "test" with an image field called "field_test_image" and I created a test node (node ID 203) and gave permission for anonymous to edit that node.
  • I also gave anonymous user permission for Services "Get any binary files", "Get own binary files", "Save file information", "Get a system variable"
  • I tried making the node resource request through both Firefox Poster plugin and curl (command line) and they both gave me the same error message above. Here are the curl commands that I've tried:
    /usr/bin/curl -v -H "Content-Type:multipart/form-data" -H "Accept: application/json" -X POST --data-binary @/Users/mona/SDSC/SEED/test_data/plots/volcano_1.0mpa.png http://myhost/services/node/203/attach_file?field_name=field_test_images
    
    /usr/bin/curl -v -H "Content-Type:multipart/form-data" -H "Accept: application/json" -X POST --data 'field_name="field_test_images"' --data-binary @/Users/mona/SDSC/SEED/test_data/plots/volcano_1.0mpa.png http://myhost/services/node/203/attach_file
    
    /usr/bin/curl -v -H "Content-Type:multipart/form-data" -H "Accept: application/json" -X POST --data-binary @/Users/mona/SDSC/SEED/test_data/plots/volcano_1.0mpa.png http://myhost/services/node/203/attach_file?field_name=field_test_images
    
  • The following curl command returned 200 OK but I could not find the file on the server nor was it attached to node 203:
    /usr/bin/curl -v http://myhost/services/node/203/attach_file -F field_name=field_test_images  -F "filename=/Users/mona/SDSC/SEED/test_data/plots/volcano_1.0mpa.png"
    

What am I doing wrong? All help is appreciated! Thanks!

Comments

kylebrowning’s picture

Status: Active » Closed (cannot reproduce)