Add file programmatically to IBM Connections Community - api

I am trying to upload files programmatically to an IBM Connections Community File library.
I am able to upload to files and then share with the community, but unfortunately is not the desired behavior.
I followed the API documentation (http://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Creating_community_files_ic50&content=apicontent)
I am sending a POST to this URL: /files/basic/api/community/{community_uuid}/introspection
I tried using a file Atom Entry document, and Content-Type:application/atom+xml
But it's not working and giving me a 405 with following error:
UnsupportedOperation
-> Request sent
POST /files/basic/api/community/00f04081-f000-4752-bd88-8b73d281fb19/introspection
Content-Type: application/atom+xml
<?xml version='1.0' encoding='UTF-8'?>
<entry
xmlns:thr='http://purl.org/syndication/thread/1.0'
xmlns:opensearch='http://a9.com/-/spec/opensearch/1.1/'
xmlns:snx='http://www.ibm.com/xmlns/prod/sn'
xmlns:td='urn:ibm.com/td'
xmlns='http://www.w3.org/2005/Atom'>
<td:label>test-restore20</td:label>
<title type="text">test-restore2</title></entry>
I tried using the same method than for stand alone file, with a basic header but still giving me a 405 with following error:
UnsupportedOperation
-> Request sent:
POST /files/basic/api/community/00f04081-f000-4752-bd88-8b73d281fb19/introspection
Content-Type: binary/octet-stream
X-Update-Nonce:<Nonce>
Slug:TMap_Next_Book.pdf
Filename: /Users/Downloads/TMap_Next_Book.pdf
When I upload to myfile, works fine
-> request sent:
POST https://greenhouse.lotus.com/files/basic/api/myuserlibrary/feed
X-Update-Nonce: <Nonce>
Slug: test-restore2
Content-Type: application/binary
Filename: /Users/Downloads/client-error-log.zip
I tried the Playground, but not well documented for that part, so so far no success.
Any of you were able to do that, and would be able to share the solution?
Thanks.

Rightfully this document should be called working with IBM Connections Community Files
http://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Creating_community_files_ic50&content=apicontent
The introspection endpoint should be called to get the "community collection document feed"
it doesn't look like you have the URL parameter which is required. You should use the URL with a GET /files/basic/api/community/3a246a15-b4d6-44e1-a01d-1c3d89f1f9a4/introspection?communityUuid=3a246a15-b4d6-44e1-a01d-1c3d89f1f9a4
Then you'll look for
Community Collection
Documents Feed
/
You'll then POST your file to the href --- https://greenhouse.lotus.com/files/basic/api/collection/e78ba00e-cee6-460f-a9ee-0350bf344e0b/feed
I've asked the team to change the title of the page.

Related

Mule 4 Anypoint Studio download file from external api

I will need to create a flow in Anypoint to download a .gz file from an external API source(through OAuth). I have created a listener -> Request -> Write flow. But I don't see the file saved in my local after I called the API. I have hardcoded Bearer token in the header and raw parameters in body, everything looks good. It doesn't show any error but when I tried to debug it and I'm seeing output and payload both are empty. I'm able to download the gz file with Postman. Am I in the right direction? I saw someone was using outbound endpoint but it is not showing in Mule 4.
Is there any way I can see what the external API returned(Success or failed)? And the content? Please advise.
Many thanks.
Regards,
Richard
Update 1:
Mule Flow
DEBUG
Added the Flow and the Debugging message. I have simplified the flow and just tried to make the POST rest call with Bearer token. It should return a json response. But still getting an empty response. Do we know what's that java.util.LinkedHashMap thing? Thanks.
Update 2:
Request Body
Request Header
XML Configuration:
XML Flow
You can add loggers to the application to trace the execution.
You could also enable HTTP wire logging to print requests/responses in the log too. To enable it you have to set the package org.mule.service.http.impl.service.HttpMessageLogger to DEBUG in the log4j2.xml or in the Runtime Manager console. Detailed instructions available at this KB article.

Unable to test an API in JMeter where I need to upload a file

can someone please help me with uploading a file on JMeter I feel its very tricky thing...
let me share the screen shot of what I've done
enter image description here
Its failing with below error:
Thread Name:jp#gc - Ultimate Thread Group 2-4
Sample Start:2021-02-04 17:28:44 IST
Load time:562
Connect Time:0
Latency:562
Size in bytes:595
Sent bytes:84568
Headers size in bytes:446
Body size in bytes:149
Sample Count:1
Error Count:1
Data type ("text"|"bin"|""):text
Response code:500
Response message:
HTTPSampleResult fields:
ContentType: application/json
DataEncoding: null
Response Body:
{"timestamp":"2021-02-04T11:58:45.482+00:00","status":500,"error":"Internal Server Error","message":"","path":"/pps/storage/upload-image"}
Request Body:
POST https://pixelperfectdevexternal.useready.com/pps/storage/upload-image
POST data:
--axOhwnTOrVj2VWGGuxcaqfjgHwGQKsTFl
Content-Disposition: form-data; name="filename"
Content-Type: image/jpeg; charset=US-ASCII
Content-Transfer-Encoding: 8bit
${filename}
--axOhwnTOrVj2VWGGuxcaqfjgHwGQKsTFl
Content-Disposition: form-data; name="filename"; filename="Passport size photo.jpeg"
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
<actual file content, not shown here>
--axOhwnTOrVj2VWGGuxcaqfjgHwGQKsTFl--
I'm totally stuck on this from last 3 weeks, I did what was told in tutorials and still its not working, someone please help me out.
We don't know how to fix the issue because we don't know how the request should look like, moreover you don't show us "Parameters" tab of the HTTP Request sampler and HTTP Header Manager configuration.
So if you have another way of successfully calling this API like curl or Postman or other tool - you should be able to record the request using JMeter's HTTP(S) Test Script Recorder, see How to Convert Your Postman API Tests to JMeter for Scaling article for example setup.
If not, you need to check your API endpoint documentation, application logs or ask around for the proper request format, once you know it you should be able to amend the request yourself or provide us more details so we could assist.

SharePoint REST API GetFileByServerRelativeUrl not working

I'm trying to fetch a file, which is downloable in the following URL https://notarealurl.com/sites/name/subname/My%20Folder/test.htm with the following method:
fetch("/_api/web/GetFileByServerRelativeUrl('/sites/name/subname/My%20Folder/test.htm')/$value");
However it returns 404. I've tried with and without decoding the URL. Also, using the following request, doesn't return any file, just an almost empty response. Request:
fetch("/_api/web/GetFolderByServerRelativeUrl('/sites/name/subname/My%20Folder')/files");
Response:
<?xml version="1.0" encoding="utf-8"?><feed xml:base="https://notarealurl.com/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"><id>ab8997b7-04a9-4e43-a63f-486e9477e31b</id><title /><updated>2020-04-08T12:00:40Z</updated><author><name /></author></feed>
The correct API URL begins from the parent directory, the correct one is:
fetch("/sites/name/subname/_api/web/GetFileByServerRelativeUrl('/sites/name/subname/My%20Folder/test.htm')/$value");
I tested the following endpoint and it works well.
_spPageContextInfo.webAbsoluteUrl/_api/web/GetFileByServerRelativeUrl('_spPageContextInfo.webServerRelativeUrl/DocuentLibraryName/DocumentName')/$value
And here is one similar threads for your reference:
How to download file from document Library using Rest Api
Best Regards,
Baker Kong

Atlassian Connect - Set entity properties in Jira/Cloud

I develop an AC/SpringBoot Jira plugin which needs to store properties in the host application. Atlassian provides Hosted Data Storage which I like to use.
I ran a test via Firefox RESTClient to play around with this feature.
When issuing a GET request to this URL:
https://kuespert-dev.atlassian.net/rest/atlassian-connect/1/addons/<MY-PLUGIN-KEY>
while being logged in to my Jira/Cloud instance on another tab everything is fine: I get back information about my plugin, including the key.
However, when issuing a PUT request to set a variable (like described in the documentation mentioned above) using this URL:
https://kuespert-dev.atlassian.net/rest/atlassian-connect/1/addons/<MY-PLUGIN-KEY>/properties/testProperty
and this request body:
{"string":"string-value","number":5}
as well as the required header:
Content-Type: application/json
I get back this response:
{
"status-code": 404,
"message": "Add-on with key does not exist."
}
This is a bit irritating, since the first REST call did find my plugin while the second to the sub-resource did not.
A similar question was already asked on the 'Atlassian Community' site, but no solution was found until today.
Maybe it's just a wrong error message or something similar. Does anybody here have experience with the 'Hosted Data Storage' feature and can help?
Thanks,
Matthias

Dropbox V2 Http API

I'm using the V2 Http API : https://www.dropbox.com/developers/documentation/http/documentation
I'm trying to post for: https://api.dropboxapi.com/2/files/get_metadata for the root folder.
my request body: {"path":""}
my headers:
Content-Type: application/json
Authorization: Bearer my_token
Dropbox-API-Select-User: dbmid:some_user_id
I'm getting a response code 400 with the body:
Error in call to API function "files/get_metadata":
request body: path: '' did not match pattern '((/|id:).*)|(rev:[0-9a-f]{9,})'
sending an empty json didnt work too.
When I'm trying to get to a folder that's not root, it works (like : "/111").
In the documentation in the "Path formats" section it says : "The empty string ("") represents the root folder".
What am I doing wrong?
Thanks!
You're correct that the root path should be indicated by the empty string "", however the /files/get_metadata endpoint doesn't support querying on the root, since there isn't any metadata to return for it anyway.
As you mentioned, and as you can see in the documentation, for any non-root folder, the path can be specified like "/Homework/math". The documentation also shows examples of specifying via id, like "id:a4ayc_80_OEAAAAAAAAAYa", or rev, like "rev:a1c10ce0dd78". The regex in the error message reflects those three options.
If your actual goal is to list the contents of root, you should instead use /files/list_folder, which does allow the root path.