Askancy Posted August 9, 2021 Share Posted August 9, 2021 (edited) I'm trying to assign an achievements via API to a user, manually. the badge is ID 17 and the user is ID 1. to try here's the code: $client = new Client(); $response = $client->request('POST','https://domain.it/api/core/members/1/achievements/17/awardbadge?key=***'); $headers = $response->getHeaders(); $body = $response->getBody(); var_dump($headers, $body); or $url = 'https://**/api/core/members/1/achievements/17/awardbadge?key=***'; $endpoint = $url; $options = [ 'form_params' => [ '$badgeId' => 17 ] ]; $client = new Client(); $request = $client->post($endpoint, $options); when I run it, without everything being ignored, even at the Log API, it does not result in the execution of this endpoint but Laravel marks me in the log: Quote Server error: `POST https://domain.it/api/core/members/1/achievements/17/awardbadge?key=***` resulted in a `500 Internal Server Error` response: how do I assign an achievements manually through api? Edited August 10, 2021 by Askancy Link to comment Share on other sites More sharing options...
Daniel F Posted August 27, 2021 Share Posted August 27, 2021 Were you able to resolve this in the meanwhile? If not, what was the logged error? On 8/9/2021 at 10:46 PM, Askancy said: resulted in a `500 Internal Server Error` response: Link to comment Share on other sites More sharing options...
Askancy Posted August 27, 2021 Author Share Posted August 27, 2021 29 minutes ago, Daniel F said: If not, what was the logged error? Blank page, I tried with: $url = 'https://forum.***.it/api/core/members/1/achievements/34/awardbadge?key=***'; $data = array('$badgeId' => 34); // use key 'http' even if you send the request to https://... $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data) ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); return $result; in Rest API Log, it doesn't even appear to be making an API request. Daniel F 1 Link to comment Share on other sites More sharing options...
Solution Daniel F Posted August 27, 2021 Solution Share Posted August 27, 2021 Thanks, there was a bug in the endpoint which will be resolved in an upcoming release. Askancy 1 Link to comment Share on other sites More sharing options...
Askancy Posted August 27, 2021 Author Share Posted August 27, 2021 3 hours ago, Daniel F said: Thanks, there was a bug in the endpoint which will be resolved in an upcoming release. I noticed that I'm registering this error for the API: ArgumentCountError: Too few arguments to function IPS\core\api\_members::POSTitem_achievements_awardbadge(), 2 passed in /var/www/vhosts/***.it/forum.****.it/system/Api/Controller.php on line 180 and at least 5 expected (0) #0 /var/www/vhosts/***.it/forum.***.it/system/Api/Controller.php(180): IPS\core\api\_members->POSTitem_achievements_awardbadge() #1 /var/www/vhosts/***.it/forum.***.it/system/Dispatcher/Api.php(329): IPS\Api\_Controller->execute() #2 /var/www/vhosts/***.it/forum.***.it/api/index.php(11): IPS\Dispatcher\_Api->run() #3 {main} Is the error fixed? I hope to implement this function soon in my cms... Link to comment Share on other sites More sharing options...
Daniel F Posted September 22, 2021 Share Posted September 22, 2021 The fix will be included in the next regular release. Askancy 1 Link to comment Share on other sites More sharing options...
Askancy Posted September 22, 2021 Author Share Posted September 22, 2021 3 hours ago, Daniel F said: The fix will be included in the next regular release. I take this opportunity to ask you something too... I use this request api to print the notifications of the logged in user: @php $url = 'https://forum.***.it/'; $apiKey = '***'; $point = '/core/members/'.\IPS\Member::loggedIn()->member_id.'/notifications'; $endpoint = $url. 'api'. $point. '?key='. $apiKey; $json = file_get_contents($endpoint); $json_data = json_decode($json, true); @endphp @foreach($json_data["results"] as $value) @if ($value["notificationData"][unread] == 'true') <strong> @endif <a href='{{$value["notificationData"]["url"]}}'> <li class="dropdown-list-item"> <span class="dropdown-list-text text-success"> @if ($value["notificationType"] == "new_badge") <i class="fas fa-certificate"></i> @else <i class="far fa-envelope"></i> @endif </span> <div class="dropdown-list-body"> {{$value["notificationData"]["title"]}} </div> </li> </a> @if ($value["notificationData"][unread] == 'true') </strong> @endif @endforeach why does it print all the notifications in English, even if the user has the language set in Italian? Otherwise, how do I tell the API request to return the notification to me in Italian? Link to comment Share on other sites More sharing options...
Stuart Silvester Posted September 22, 2021 Share Posted September 22, 2021 I have created a bug report for this so we can look into it further. Askancy 1 Link to comment Share on other sites More sharing options...
Recommended Posts