#!/usr/bin/python
# coding: utf-7

import json
import requests

url = 'http://localhost:5000/api/v1/object-issue'

data = '''
{
    "object": 
    {
        "title": "Check that the route cache is flushed after NIC change",
        "categories": [
            "team:orange",
            "topic:ip",
            "subtopic:route-cache"
        ],
        "description": [
            {
                "type": "main",
                "mime-type": "text/markdown",
                "data": "a mardown formatted long text encoded in base64"
            },
            {
                "type": "media",
                "mime-type": "media/png",
                "description": "image of the routing architecture and test setup",
                "name": "image-foo.png",
                "data": "<base64 encoded image>"
            }
        ],
        "version": 0,
        "data": [
            {
                "description": "network configuration script",
                "file-name": "network-config.sh",
                "mime-type": "text/plain",
                "data": "<base64 encoded data>"
            }
        ]
    },
    "attachment": {
        "references": [ "doors:234236", "your-tool:4391843" ],
        "replaces":   [ "14d348a14934a02034b", "43348a234434934f0203421" ],
        "tags":       [ "ip", "route", "cache", "performance" ]
        },
    "achievements": [
        {
            "submitter": "John Doe <john.doe@example.com>",
            "test-date": "2015-09-15T22:24:29.158759",
            "result": "passed",
            "sender-id": "virgo.skynet.local",
            "data" : [
                        {
                            "description": "foo-bar pcap file",
                            "file-name":   "network-config.sh",
                            "mime-type":   "binary/octet-stream",
                            "data":        "<base64 encoded data>"
                        }
                     ]
        }
    ]
}
'''

headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
r = requests.post(url, data=data, headers=headers)
#r = requests.post(url, data=json.dumps(data), headers=headers)
print(r.status_code)
print(r.json())

@@ -103,14 +103,8 @@
 ject
--issue
 '%0A%0Ad
@@ -126,16 +126,21 @@
  %22object
+-item
 %22: %0A    
@@ -229,140 +229,12 @@
    %22
-categories%22: %5B%0A            %22team:orange%22,%0A            %22topic:ip%22,%0A            %22subtopic:route-cache%22%0A        %5D,%0A        %22description
+data
 %22: %5B
@@ -433,83 +433,8 @@
   %7B%0A
-                %22type%22: %22media%22,%0A                %22mime-type%22: %22media/png%22,%0A
     
@@ -529,16 +529,21 @@
        %22
+file-
 name%22: %22
@@ -579,104 +579,190 @@
    %22
-data%22: %22%3Cbase64 encoded image%3E%22%0A            %7D%0A        %5D,%0A        %22version%22: 0,%0A        %22data%22: %5B
+mime-type%22: %22media/png%22,%0A                %22data%22: %22iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==%22%0A            %7D,
 %0A   
@@ -957,62 +957,300 @@
 %22: %22
-%3Cbase64 encoded data%3E%22%0A            %7D%0A        %5D
+iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==%22%0A            %7D%0A        %5D,%0A        %22categories%22: %5B%0A            %22team:orange%22,%0A            %22topic:ip%22,%0A            %22subtopic:route-cache%22%0A        %5D,%0A        %22version%22: 0
 %0A    %7D,%0A
     
@@ -1241,24 +1241,26 @@
 %22: 0%0A    %7D,%0A
+%0A%0A
     %22attachm
@@ -1288,16 +1288,17 @@
 rences%22:
+ 
  %5B %22door
@@ -1350,16 +1350,17 @@
 places%22:
+ 
    %5B %2214
@@ -1430,16 +1430,17 @@
 :       
+ 
 %5B %22ip%22, 
@@ -1472,16 +1472,74 @@
 mance%22 %5D
+,%0A        %22responsible%22: %22John Doe %3Cjohn.doe@example.com%3E%22
 %0A       
@@ -1538,24 +1538,26 @@
 %0A        %7D,%0A
+%0A%0A
     %22achieve
@@ -2053,37 +2053,125 @@
 a%22: 
-       %22%3Cbase64 encoded data%3E
+%22iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==
 %22%0A  

add base64 coding example