Hunting the internet further I found the issue. I needed to find a way to get more information from Powershell errors.
It told me the ContentType was incorrect. It was expecting the -ContentType 'text/xml'
Once I set this, the Invoke-RestMethod worked with PUT and the PI server returned a job number as expected.
However, the PI server indicated the job failed. I can only capture a portion of the error message. It is griping about the snmp_version. However, I am not trying to change the snmp_version, just a UDF.
FAILED_Add Bulk Import Job Failed, Incorrect Input file. Line 2: Invalid value : '' for snmp_version Possible Values are : 1 , 2c , 3.-INVENTORY
I have no idea why it is throwing this error message. Can the community help in properly formatting the XML input?
The op/devices/bulkImport resource expects a full set of device credentials to be sent in the request payload, even in the case of updating a UDF. The recommended workflow is to use op/devices/exportDevices to export the device(s) in question, use the response from that resource as a baseline to make your UDF changes, then PUT that to op/devices/bulkImport. Let me know if you run into any further issues.
Thanks for the reply. What I discovered was that the /op/devices/bulkImport requires a MINIMUM of three entries being passed to it to make an update to the UDF. IP address, SNMP version and SNMP community. The API documentation only indicates the IP address is mandatory. I found this not to be the case. All three are required to make a successful update to the UDF.
Posting this here so other community members can see how I resolved the issue.