1
votes

I am trying to create a new node using services module and testing with POSTER extension of google crome. This node has custom image field, now facing trouble with; how to pass values for the image field.

Node Type: 'article' Node fields: 'title', 'body', 'article_image'

1

1 Answers

2
votes

You need two steps to achieve this. First upload the file and get the fid and then you post the article with fid included.

step 1 example:

{
    "filename": "arkadikos_default_image.jpg",
    "target_uri": "pictures/arkadikos_default_image.jpg",
    "filemime": "image/jpg",
    "file": "/9j/4QAYRXh..",
    "filesize": "29000"
}

step 2 example:

{
    "title": "My title",
    "type": "article",
    "language": "el",
  "body" : {
        "und": [
            {
                "value": "test text"
            } ]
  },
  "field_image": { 
        "und": [ 
          { 
            "fid": "1364" 
          } 
        ]
  }

}