So i'have a Alfresco Community server (5.2.X and 6.2.X), i have prepared a retrofit2 client for communicate with the rest api of Alfresco, it's work just fine with all the services, but there is some strange error when i try to upload a file with the "createNode" post method of the rest api with contentype "multipart/form-data".
Here the retrofit 2 code for upload a file with the rest api:
@Multipart
@POST("nodes/{nodeId}/children")
Call<NodeEntry> createNodeCall(
@retrofit2.http.Path("nodeId") String nodeId,
//@retrofit2.http.Body NodeBodyCreate nodeBodyCreate, //Removed because is the multipart/form-data
@retrofit2.http.Query("autoRename") Boolean autoRename,
@retrofit2.http.Query("include") CSVParams include,
@retrofit2.http.Query("fields") CSVParams fields,
@retrofit2.http.PartMap() Map<String, RequestBody> partMap, //Added because is the multipart/form-data
@retrofit2.http.Part MultipartBody.Part filedata //Added because is the multipart/form-data
);Here the content of the "partMap" map:
"name" = "ifc-32.png"
"nodeType" = "cm:content"
"relativePath" = null
"association" = null
"secondaryChildren" = null
"targets" = null
other properties with key-value relationship but in this case there are no ones...
The strange thing is i doesn't get a 404 or 401 or some other common issue, but instead Alfresco tell me this strange error:
{
"error":{
"errorKey":""cm:content" isn't a valid QName. Namespace prefix "cm is not mapped to a namespace URI",
"statusCode":400,
"briefSummary":"10130018 "cm:content" isn't a valid QName. Namespace prefix "cm is not mapped to a namespace URI",
"stackTrace":"Per motivi di sicurezza l'analisi dello stack non viene più visualizzata, ma viene mantenuta la proprietà per le versioni precedenti",
"descriptionURL":"https://api-explorer.alfresco.com"
}
}What that is mean??? "cm:content" is the de facto standard type of documents... i don't understand...
The default value is still "cm:content" so i just set :
"nodeType" = null
and try again.
After that a similar error is showed up for the "name" parameter. Here the error i get after send the nodetype and name with null value:
{
"error":{
"errorKey":"framework.exception.ApiDefault",
"statusCode":422,
"briefSummary":"10130069 Found 1 integrity violations: Invalid property value: Node: workspace://SpacesStore/ed95ec75-0240-40ed-8f36-c7ad19cd3262 Name: "ifc-32.png" Type: {http://www.alfresco.org/model/content/1.0}content Property: {http://www.alfresco.org/model/content/1.0}name Constraint: 10130068 Value '"ifc-32.png"' is not valid as a file name. This property must be a valid file name.",
"stackTrace":"Per motivi di sicurezza l'analisi dello stack non viene più visualizzata, ma viene mantenuta la proprietà per le versioni precedenti",
"descriptionURL":"https://api-explorer.alfresco.com"
}
}So i removed the name parameter :
"name" = null
and now it's finally work why ???