LimeSurvey version: LimeSurvey Cloud Version 6.6.7
==================
Hello, I am trying to communicate with LSRC2 API. I started from fetching session key but can't get it due to CORS error each time I try to send request. I send it from locally served angular app. Here is my Interfaces tab configuration from Global settings:
RPC interface enabled: JSON-RPC
Publish API on /admin/remotecontrol: On
Set Access-Control-Allow-Origin header: On
Code snippet:
Code:
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class LimeSurveyService {
private sessionKey: string | null = null;
private limeApiUrl =
'https://xxxxxxxx.limesurvey.net/admin/remotecontrol';
private username = 'username';
private password = 'password';
constructor(private http: HttpClient) {}
loginAndGetSessionKey$(): Observable<any> {
const params = {
method: 'get_session_key',
params: [this.username, this.password],
plugin: 'Authdb',
};
const headers = new HttpHeaders({
'Content-Type': 'application/json',
'connection': 'Keep-Alive',
});
return this.http.post(this.limeApiUrl, params, {
headers: headers,
});
}
}
Thanks in advance.