Hello, Is it away to get how many posts created by specific user?
using - Flutter SDK
Thanks
Hi @meridork ,
Are you trying to get post from community or user feed? Can you please help elaborate?
Thank you,
Amity Support
How many posts the user uploaded. to all communities
The idea to get the activity of the user
I did it with following command in api-docs and its working
curl -X 'GET' \
'https://api.eu.amity.co/api/v3/user-feeds/allerg.meridor%40gmail.com/count' \
-H 'accept: application/json' \
-H 'Authorization: Bearer xxxxxxxxxxxxxxxxxx'
But the following command got following error in my code
command
var resp = await http.get(Uri.parse(āhttps://api.eu.amity.co/api/v3/user-feeds/allerg.meridor%40gmail.com/countā));
error
I/flutter (11557): kobi - http 401 {
I/flutter (11557): āstatusā: āerrorā,
I/flutter (11557): āmessageā: āAuthorization info not foundā,
I/flutter (11557): ācodeā: 400100,
I/flutter (11557): ādataā: {
I/flutter (11557): ādetailā: {
I/flutter (11557): āappErrorCodeā: 400100
I/flutter (11557): }
I/flutter (11557): }
I/flutter (11557): }
Currently, you can only get post specific from either user feed/community feed.
At the moment, our sdk doesnāt provide the option to get posts from community by userid.
From your api that is working, it seems that you tried to get user feedās posts which is correct and it works as expected.
curl -X 'GET' \
'https://api.eu.amity.co/api/v3/user-feeds/allerg.meridor%40gmail.com/count' \
-H 'accept: application/json' \
-H 'Authorization: Bearer xxxxxxxxxxxxxxxxxx'
However for the code below, the error indicates that the Authorization is missing.
command
var resp = await http.get(Uri.parse(āhttps://api.eu.amity.co/api/v3/user-feeds/allerg.meridor%40gmail.com/countā));
error
I/flutter (11557): kobi - http 401 {
I/flutter (11557): āstatusā: āerrorā,
I/flutter (11557): āmessageā: āAuthorization info not foundā,
I/flutter (11557): ācodeā: 400100,
I/flutter (11557): ādataā: {
I/flutter (11557): ādetailā: {
I/flutter (11557): āappErrorCodeā: 400100
I/flutter (11557): }
I/flutter (11557): }
I/flutter (11557): }
This is the API
curl -X 'GET' \
'https://api.eu.amity.co/api/v3/user-feeds/allerg.meridor%40gmail.com/count' \
-H 'accept: application/json' \
-H 'Authorization: Bearer'
Where do I need to add the accessToken?
Could you help us confirm whether the API is causing the problem or if itās an issue with the code? In your earlier comment, you mentioned the API was fine, but the code wasnāt working.
issue with the code
where to add the token? to the API GET
I found
url = Uri(
scheme: 'https',
host: 'api.eu.amity.co',
path: '/api/v3/user-feeds/${eMail}/count',
);
var r1 = await http.get(
url,
headers: {
'accept': 'application/json',
'Authorization': 'Bearer $accessToken',
},
);
Its working on mobile and only one of the users
The user is allerg.meridor@gmail.com and defined as Admin
And the user created posts and the counter was not incremented
Thanks
Another question about number of posts and its relevance to other issues
Can I get number of post created by another user
If you manage to get the post by following the instructions we provided, then you should be able to get the number of posts by count
Hello,
This is the code and the postsCount is wrong
All the https post/get status are OK , 200
Thanks
Uri url = Uri(
scheme: 'https',
host: 'api.eu.amity.co',
path: '/api/v3/sessions',
);
var body = json.encode({
"userId": "string",
"deviceId": "string",
"deviceInfo": {
"kind": "ios",
"model": "string",
"sdkVersion": "string"
},
"displayName": "string",
"authToken": "string"
});
var r = await http.post(
url,
headers: {
'accept': 'application/json',
'x-api-key': 'b0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx2c',
'Content-Type': 'application/json',
},
body: body,
);
Map bodyMap = jsonDecode(r.body);
String accessToken = bodyMap['accessToken'].toString();
url = Uri(
scheme: 'https',
host: 'api.eu.amity.co',
path: '/api/v3/user-feeds/${eMail}/count',
);
body = json.encode({
"userId": "string",
"deviceId": "string",
"deviceInfo": {
"kind": "ios",
"model": "string",
"sdkVersion": "string"
},
"displayName": "string",
"authToken": "string"
});
var r1 = await http.get(
url,
headers: {
'accept': 'application/json',
'Authorization': 'Bearer $accessToken',
},
);
bodyMap = jsonDecode(r1.body);
postsCounuter = bodyMap['postsCount'];
Which token did you use in this code? Does it belong to another user?
is was created in the first HTTPS for the same user
allerg.meridor@gmail.com
To retrieve the posts of a specific user, you will need to use their token. We suggest following the APIs mentioned in this topic: Get post created by following for guidance.