Put a request to the Connections Administration API from a Lotusscript agent

I followed the documentation (here) to put a request to the Connections Administration API from a Lotusscript agent. Here a summary of the script :

url = "https://connections.mycompany.com/profiles/admin/atom/profileEntry.do?key=1620049a-3d2c-44a2-b378-6f7a6a87a414"
Set webRequest = session.CreateHTTPRequest()
webrequest.preferstrings = True 'if not error contenttype unsupported
Call webRequest.SetHeaderField("Authorization", "Basic " + encodeBase64) 'username:password encoded base64
Call webRequest.SetHeaderField("Content-Type","application/atom+xml")
call webRequest.put(url,body)
MsgBox webRequest.Responsecode 'HTTP/1.1 Bad Request

body is a string that contains the information profile to update :

body = |<?xml version="1.0" encoding="UTF-8"?>|
body = body + |<entry xmlns:app="http://www.w3.org/2007/app" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:fh="http://purl.org/syndication/history/1.0" xmlns:snx="http://www.ibm.com/xmlns/prod/sn" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom">|
body = body + |<id>tag:profiles.ibm.com,2006:entry1620049a-3d2c-44a2-b378-6f7a6a87a414</id><category term="profile" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category>|
body = body + |<content type="application/xml"><person xmlns="http://ns.opensocial.org/2008/opensocial"><com.ibm.snx_profiles.attrib>|
body = body + |<entry><key>com.ibm.snx_profiles.base.jobResp</key><value><type>text</type><data>Information to update</data></value></entry>|
body = body + |</com.ibm.snx_profiles.attrib></person></content></entry>|

but it doesn't work and the request response code is "HTTP/1.1 Bad request"

I used postman with exactly the same informations, that's run, the profile is updated

I have no problem with user right or authentification API because if i use the following script to retrieve profile informations, thats run :

url = https://connections.mycompany.com/profiles/admin/atom/profileEntry.do?email=myname@mycompany.com
Set webRequest = session.CreateHTTPRequest()
webrequest.preferstrings = True	
Call webRequest.SetHeaderField("Authorization", "Basic " + encodeBase64)
response = webRequest.get(url)
msgbox response 'user profile informations

Does anyone have any idea or experience with this type of query ?

Thanks for your help !

Hi,

mmm I have to edit my post:

Did ou see the instructions in the documentation:

1. Retrieve the profile entry for Madeleine by sending the following request:
GET /profiles/admin/atom/profileEntry.do?email=mbrown%40example.com
2. Make a copy of the returned entry document.
3. In the copy, edit the value of the <data> element associated with the com.ibm.snx_profiles.base.displayName <key> element to read as follows:
4. Do not remove or edit any other entries. Save and close the updated profile entry.
5. Update Maddie's profile in the Profiles database by sending a PUT request to the web address specified in the edit link of her profile document. 

According to this document, your PUT is much too small. Maybe you try to delete (because it is not in the document) some undeletable fields.

Try to honor instructions 3. and 4. so only modify the retrieved document and do not create a completely new one.

(of course, this is XML editing in LS. But Live is not easy. :-) )

Martin

thank you for your interest !

I think it's ok because when i put exactly the same xml informations with Postman, that's work, and the profile is updated.

As i writted, the same request (url, authentification, body, content type) work with Postman, strange.

Hi Fred,

Have you used a tool (e.g. Fiddler or Wireshark) to capture the client based communication with the server? If the LotusScript and Postman requests are exactly the same, there should not be a differing result, so that may be an approach to help identify a difference.

Thanks,
Michael Montani
HCL Support

The origin of the problem was the base64 encoding of the "username: password" in the basic authorization header with Lotusscript.

But i didn't research this side first because the API requests to retrieve the profiles (get) work correctly with the same basic authorization, only the update (put) requests are problematic, strange !

So, i use a different way to encode authorization and everythings works perfect now !!!