Adding user to group does nothing

  • 1
  • Problem
  • Updated 1 year ago
I want to add a user to a distribution group, but even though the response comes back with a 200 response code, the "updated list of contacts" that I should get back does not show the User I wanted to add and when I check in the web interface, the user is indeed not added to the group.
I post to:
Groups(g0b59172-0530-48b2-9dd8-a960890289a4)/Contacts
I've tried the following post body form_fields:
'contacts' => ['Id' => '2bdb8c73-6239-45aa-8fd4-ef90d01cb262'],
'contacts' => ['Email' => 'valid.employee@email.com'],
'Id' => '2bdb8c73-6239-45aa-8fd4-ef90d01cb262',
But none of these seem to do anything (and all of them give a 200 response code).
Photo of Rick Cuijpers

Rick Cuijpers

  • 13 Posts
  • 1 Reply Like
  • frustrated

Posted 1 year ago

  • 1
Photo of Suprit

Suprit, Employee

  • 11 Posts
  • 2 Reply Likes
Rick,

In our records, it is indicated that the user ('2bdb8c73-6239-45aa-8fd4-ef90d01cb262') was added to the group ('g0b59172-0530-48b2-9dd8-a960890289a4').

Can you please check again and tell us if the user is in the distribution group, and do let us know if you see any issues.

Thanks,
Suprit
Photo of Rick Cuijpers

Rick Cuijpers

  • 13 Posts
  • 1 Reply Like
Hello,

After I failed adding the user with the API, I've added it to the group using the web-interface.
For support purposes, I've tried adding the user to a different group with the following command:

POST to:
https://triptic.sharefile.com/sf/v3/Groups(gb588a42-8cda-48d8-9e9e-5c6ca59d7c27)/Contacts
With parameters:
[
    "headers" => (1)[
        "Authorization" => (73)"Bearer [[valid-token]]"
    ]
    "form_params" => (1)[
        "contacts" => (1)[
            "Id" => (36)"2bdb8c73-6239-45aa-8fd4-ef90d01cb262"
        ]
    ]
]
And that results in a 200 response with the following content:
[
    "odata.metadata" => (54)"https://triptic.sharefile.com/sf/v3/$metadata#Contacts"
    "odata.count" => 0
    "value" => []
    "url" => (44)"https://triptic.sharefile.com/sf/v3/Contacts"
]
And when I check in the web-interface, it isn't added. I've also tried it with the following parameters:
[
    "headers" => (1)[
        "Authorization" => (73)"Bearer [[valid-token]]"
    ]
    "form_params" => (1)[
        "contacts" => (1)[
            "Email" => (21)"J.Berkvens@Triptic.nl"
        ]
    ]
]
With the same result.
(Edited)
Photo of Suprit

Suprit, Employee

  • 11 Posts
  • 2 Reply Likes
Hello Rick,

Can you provide an HTTP trace of the request, so we can better assist you in fixing the issue.

Thank you!

Best Regards,
Suprit
Photo of Rick Cuijpers

Rick Cuijpers

  • 13 Posts
  • 1 Reply Like
Hello Suprit,

How do I get the HTTP trace of the request (I work with PHP)?
Photo of Suprit

Suprit, Employee

  • 11 Posts
  • 2 Reply Likes
Hello Rick,

You can use any of the third party software available to record the HTTP request and response.
You can upload the details to https://suprit.sharefile.com/r-r977650cc95246d5b

Thank you!

Regards,
Suprit
Photo of Rick Cuijpers

Rick Cuijpers

  • 13 Posts
  • 1 Reply Like
Hello Suprit,
I haven't been able to get a trace through third party software yet, but I did find a debug option in Guzzle and that gave me this information:


* Found bundle for host triptic.sharefile.com: 0x55ed4cdb27e0 [can pipeline]
* Re-using existing connection! (#0) with host triptic.sharefile.com
* Connected to triptic.sharefile.com (52.3.211.188) port 443 (#0)
> POST /sf/v3/Groups(gb588a42-8cda-48d8-9e9e-5c6ca59d7c27)/Contacts HTTP/1.1
Host: triptic.sharefile.com
User-Agent: GuzzleHttp/6.2.1 curl/7.52.1 PHP/7.0.22-2+ubuntu17.04.1+deb.sury.org+1
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer [[valid-token]]
Content-Length: 43

* upload completely sent off: 43 out of 43 bytes
< HTTP/1.1 200 OK
< Cache-Control: no-cache
< Pragma: no-cache
< Content-Type: application/json; charset=utf-8
< Content-Language: en-US
< Expires: -1
< Server: Microsoft-IIS/8.5
< X-SFAPI-RequestID: 636457092854713393
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: DENY
< Set-Cookie: SFAPI_AuthID=[[auth-id]]; domain=triptic.sharefile.com; path=/; secure; HttpOnly
< X-Robots-Tag: noindex
< Date: Wed, 08 Nov 2017 08:41:25 GMT
< Content-Length: 155
< X-SF-Server: api_new_ssl_v3/i-03d72f46a7d30e746_172.16.107.159_us-east-1c
< Strict-Transport-Security: max-age=16000000; includeSubDomains; preload;
< Set-Cookie: SFAPI_SRVNAME=i-03d72f46a7d30e746; path=/
< 
* Curl_http_done: called premature == 0
* Connection #0 to host triptic.sharefile.com left intact
I hope that this also helps.
Photo of Rick Cuijpers

Rick Cuijpers

  • 13 Posts
  • 1 Reply Like
I think I got the trace working. Is this what you're looking for:
https://triptic.sharefile.com/sf/v3/Groups(gb588a42-8cda-48d8-9e9e-5c6ca59d7c27)/Contacts
Id: f992d54b-9172-4650-ae9f-c9594905f9ee

POST https://triptic.sharefile.com/sf/v3/Groups(gb588a42-8cda-48d8-9e9e-5c6ca59d7c27)/Contacts
Accept: application/json, text/javascript, */*; q=0.01
Origin: https://dev.irisintranet.com
X-DevTools-Emulate-Network-Conditions-Client-Id: b4a90527-9ce7-4ab6-8e5a-338d1ac5ce7c
Authorization: Bearer [[valid-token]]
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: https://dev.irisintranet.com/~jberkvens/projects/dev-jberkvens/test.triptic.net/tmp/tmp.php
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.8,nl;q=0.6
x-qdo-developer: 1

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Content-Encoding: gzip
Content-Language: en
Expires: -1
Vary: Accept-Encoding
Server: Microsoft-IIS/8.5
Access-Control-Allow-Origin: https://dev.irisintranet.com
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type,X-HTTP-Method-Override,X-SF-App,Authorization,X-SF-ClientCapabilities,X-SF-LimitedAuthId,X-SF-CaptchaUserToken
X-SFAPI-RequestID: 636457131636377840
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
X-Frame-Options: DENY
Set-Cookie: SFAPI_AuthID=[[auth-id]]; domain=triptic.sharefile.com; path=/; secure; HttpOnly
X-Robots-Tag: noindex
Date: Wed, 08 Nov 2017 09:46:03 GMT
Content-Length: 120
X-SF-Server: api_new_ssl_v3/i-0f82e5d05dfed9dbd_172.16.107.12_us-east-1c
Strict-Transport-Security: max-age=16000000; includeSubDomains; preload;
Set-Cookie: SFAPI_SRVNAME=i-0f82e5d05dfed9dbd; path=/
(Edited)
Photo of Suprit

Suprit, Employee

  • 11 Posts
  • 2 Reply Likes
Hello Rick,

From the trace, it looks like you are missing body for the request.

In order to add a contact to an existing group, you can make the following HTTP request with content:
POST https://triptic.sharefile.com/sf/v3/Groups(gb588a42-8cda-48d8-9e9e-5c6ca59d7c27)/Contacts
Body Content- [{"Id":"f992d54b-9172-4650-ae9f-c9594905f9ee"}] 

Also, The Content-Type in the request header needs to be application/json
Content-Type: application/json;
Could you try the above mentioned changes and do let us know if you face any issues.

Thank you!

Regards,
Suprit
Photo of Rick Cuijpers

Rick Cuijpers

  • 13 Posts
  • 1 Reply Like
Thank you very much for the help, the problem was indeed the content-type. I forgot to log the request body. It seems that everything is working now.