I tried to create a node through external application using web services. This having only two fields node title and cck field image. i will grateful if anyone share the JSON format to post the images. I tried using format that mentioned below link but its failed means image not uploaded.

https://www.drupal.org/node/2195165

Any one guide me do this.

Thanks..

Comments

natefollmer’s picture

Attaching files are a two step process. The link you provided is step 1, now you need to do step 2.

When attaching files to nodes, you give the node the fid (file id) NOT the path. If you want to see exactly what your JSON needs to look like, the easiest way I have found is make a node on the site as you normally would, then call [PathToYourServicesServer]/node/[nid].json and this will return what your JSON should look like.

A quick example might look like this:

{
   "title":"Title of Node",
   "field_image": {
        "und": [{
            "fid": response.fid,
        }]
    }

}

That's it! So to summarize, follow the tutorial in your link, then take your response, get the fid, and use that to pass the fid to your node to attach the file.

kylebrowning’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

chandu7929’s picture

Hi,

Is there way to attached uploaded image to comment field?

Thanks,
Chandan