Unable to create document using WebXtender REST API

Options

I keep getting the following error when trying to create a document:

"The HTTP request does not contain index information to create a AX document!"

Not sure what's really causing this error because I am providing the index information.

Here's my python script:

## TEST UPLOADING DOC

urlDev = 'http://localhost/appxtenderrest/api/axdatasources/db/'

appID = 108

URI = urlDev+"axdocs/"+str(appID)

testFilePath = 'test-document.pdf'

testDocOpen = open(testFilePath, 'rb')

testDoc = {"file": (testFilePath, testDocOpen)}

headers = {'Accept':'application/vnd.emc.ax+json'}


## index info

data={}

data['TargetDoc'] = {"ID":None}

data['NewIndex'] = {"indexid":None, "values":[{"FieldID":"field1","FieldValue":"PDF"},{"FieldID":"field2","FieldValue":"TEST DOCUMENT"},{"FieldID":"field3","FieldValue":"0"}]}

data['FromBatch'] = {"ID":None}

data['BatchPageNum'] = None

data['IgnoreDuplicateIndex'] = False

data['IgnoreDlsViolation'] = False


#print(data)


axDocPOST = requests.post(URI, json=data, files=testDoc, headers=headers, auth=HTTPBasicAuth(userDev, passDev))

print (axDocPOST.json())

print (axDocPOST.headers)


print('status code:', axDocPOST.status_code)


if axDocPOST.status_code == 201:

  print ("Success")

else:

  print ("Failure")

Tagged:

Comments