Stephane,
Yes, you can update indexes from the Platform SDK API.
Did you read my responses on the other thread you posted about using the Platform SDK? That would be a good place to start, as it lays the foundation for non-.NET Platform SDK usage (Visual Foxpro, in my examples).
Once that code/methodology is understood, here is our routine that updates indexes:
=====================
PROCEDURE DWUpdateDocumentIndexes
LPARAMETERS pcFileCabinetName, pnDWDocID, paIndexes, pcError
EXTERNAL ARRAY paIndexes
pcError = ""
IF (VARTYPE(pcFileCabinetName) == "C") AND (NOT EMPTY(pcFileCabinetName))
pcFileCabinetName = ALLTRIM(pcFileCabinetName)
ELSE
* File cabinet name is required.
MESSAGEBOX("File cabinet name (parameter 1) must be a non-empty string passed to DWUpdateDocumentIndexes().", 64, "Invalid Parameter")
RETURN .F.
ENDIF
IF (VARTYPE(pnDWDocID) == "N") AND (pnDWDocID > 0)
pnDWDocID = INT(pnDWDocID)
ELSE
* Positive integer representing document ID must be passed in.
MESSAGEBOX("DW Document ID (parameter 2) must be a positive integer passed to DWUpdateDocumentIndexes().", 64, "Invalid Parameter")
RETURN .F.
ENDIF
IF (TYPE("ALEN(paIndexes)") <> "N")
* Index array (passed by reference) is required.
MESSAGEBOX("Index array (parameter 3) must be passed by reference to DWUpdateDocumentIndexes().", 64, "Invalid Parameter")
RETURN .F.
ENDIF
IF (ALEN(paIndexes, 2) <> 2)
* Index array needs to have 2 columns.
MESSAGEBOX("Index array must have two columns for use in DWUpdateDocumentIndexes().", 64, "Invalid Parameter")
RETURN .F.
ENDIF
SET PROCEDURE TO GlobalProc ADDITIVE
LOCAL llSuccess, lcFileCabinetGUID, i, lcSDKResource, lcResponseError, lnDocumentID, loErr, lcPostData, ;
lcFieldName, luFieldValue, lcFieldType, lcFieldValueAsString
llSuccess = .T.
lcFileCabinetGUID = DWGetFileCabinetGUID(pcFileCabinetName)
IF EMPTY(lcFileCabinetGUID)
pcError = 'File cabinet "' + pcFileCabinetName + '" could not be found.'
llSuccess = .F.
ENDIF
lcPostData = ""
IF llSuccess
* Create index data as an XML string. Header information, etc. (e.g. XML namespace values) need to match what
* would come back from a query that returns the same type of data we are sending up (in this case, document index fields).
lcPostData = lcPostData + [<?xml version="1.0" encoding="utf-8"?>]
lcPostData = lcPostData + [<?xml-stylesheet type="text/xsl" href="/DocuWare/Platform/Content/standard.xslt"?>]
lcPostData = lcPostData + [<DocumentIndexFields xmlns:s="http://dev.docuware.com/schema/public/services" xmlns="http://dev.docuware.com/schema/public/services/platform">]
FOR i = 1 TO ALEN(paIndexes, 1)
lcFieldName = ALLTRIM(TRANSFORM(paIndexes[i, 1]))
luFieldValue = paIndexes[i, 2]
lcFieldType = VARTYPE(luFieldValue)
lcFieldValueAsString = TRANSFORM(luFieldValue)
* 10/31/2017 - JLK - Discovered that trying to use numeric tags in the XML doesn't work. No error
* is thrown, but the index does not save. Passing numeric indexes as strings, however, works.
* So, for all text and numeric indexes, just pass them in as strings and let DocuWare convert them.
DO CASE
CASE INLIST(lcFieldType, "C", "I", "N", "B", "F")
lcFieldType = "String"
lcFieldValueAsString = EscapeXmlLiteral(TRANSFORM(luFieldValue))
CASE (lcFieldType = "D")
lcFieldType = "Date"
lcFieldValueAsString = ALLTRIM(STR(YEAR(luFieldValue))) + [-]
lcFieldValueAsString = lcFieldValueAsString + PADL(MONTH(luFieldValue), 2, "0") + [-]
lcFieldValueAsString = lcFieldValueAsString + PADL(DAY(luFieldValue), 2, "0")
CASE (lcFieldType = "T")
* Date/time fields need to be converted to UTC for storage in DocuWare.
luFieldValue = LocalToUTC(luFieldValue)
lcFieldType = "DateTime"
lcFieldValueAsString = ALLTRIM(STR(YEAR(luFieldValue))) + [-]
lcFieldValueAsString = lcFieldValueAsString + PADL(MONTH(luFieldValue), 2, "0") + [-]
lcFieldValueAsString = lcFieldValueAsString + PADL(DAY(luFieldValue), 2, "0") + [T]
lcFieldValueAsString = lcFieldValueAsString + PADL(HOUR(luFieldValue), 2, "0") + [:]
lcFieldValueAsString = lcFieldValueAsString + PADL(MINUTE(luFieldValue), 2, "0") + [:]
lcFieldValueAsString = lcFieldValueAsString + PADL(SEC(luFieldValue), 2, "0") + [Z]
OTHERWISE
* Unknown field type. Treat it as a string.
lcFieldType = "String"
lcFieldValueAsString = luFieldValue
ENDCASE
lcPostData = lcPostData + [<Field FieldName="] + lcFieldName + [">]
lcPostData = lcPostData + [<] + lcFieldType + [>] + lcFieldValueAsString + [</] + lcFieldType + [>]
lcPostData = lcPostData + [</Field>]
ENDFOR
lcPostData = lcPostData + [</DocumentIndexFields>]
ENDIF
IF llSuccess
lcSDKResource = "/DocuWare/Platform/FileCabinets/" + lcFileCabinetGUID + "/Documents/" + ALLTRIM(STR(pnDWDocID)) + "/Fields"
TRY
IF DWInitPlatformService(, @pcError)
* We are authenticated. We will continue to manipulate the request object here.
* Indexing requires us to POST to the SDK resource with data representing updated indexes (created above).
_DWPlatformService.Open("POST", DW_PROTOCOL + "://" + DW_SERVER + lcSDKResource)
_DWPlatformService.Send(lcPostData)
* Check the response to the request to see if we were successful.
IF ParseXML(_DWPlatformService.ResponseText, "_tempResponse")
* We were able to parse the response XML. Make sure the response has a document ID, and grab it.
* First, check for an error.
lcResponseError = DWGetNodeTextFromSDKResponseCursor("_tempResponse", "/Error/", "Message")
IF EMPTY(lcResponseError)
* No error found. Verify document ID in response.
lnDocumentID = VAL(DWGetNodeTextFromSDKResponseCursor("_tempResponse", "/DocumentIndexFields/", "Field", "FieldName", "DWDOCID"))
IF (lnDocumentID <> pnDWDocID)
pcError = "Index operation did not return an error, but correct Document ID could not be found in response."
llSuccess = .F.
ENDIF
ELSE
* Error found.
pcError = lcResponseError
llSuccess = .F.
ENDIF
ELSE
* We could not parse the response XML. Something must be wrong.
pcError = "Indexing response was not valid XML. An unknown error occurred. ResponseText was:" + CHR(10) + CHR(10) + _DWPlatformService.ResponseText
llSuccess = .F.
ENDIF
USE IN SELECT("_tempResponse")
ELSE
llSuccess = .F.
ENDIF
CATCH TO loErr
SET CONSOLE OFF
pcError = loErr.Message
llSuccess = .F.
ENDTRY
ENDIF
RETURN llSuccess
ENDPROC
=====================
The basics here are that you pass in a file cabinet name which then converts to a GUID (or you can just use GUID). Then, an array of index/value pairs is assembled into XML. You can also use JSON for the POST data, but I had better luck with XML when I was first trying to get this stuff to work -- I am just not as well-versed in JSON habits.
Once you have the resource URL created and tghe XML assembled, you post it. You can then analyze the reponse to make sure an error did not occur (the XML response should list all the indexes for the document now in effect).
You appear to be using the correct URL for all this.
I know the above code works, because we use it all the time.
Good luck,
Joe Kaufman