Creazione richiesta di trasmissione “Comunicazioni Finanziarie” in formato zip.
curl -X POST https://testws.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequestList?username=Utente&password=Password \
-H 'Accept: application/json' \
-H 'Content-Type: application/json;charset=UTF-8' \
-d '{
"userName" : "Utente",
"password" : "Password",
"userID" : "Utente",
"comunicationType" : "LI",
"dataFile" : "dGVzdA=="
}'
#include <C_CkRestW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
BOOL bTls;
int port;
BOOL bAutoReconnect;
HCkJsonObjectW json;
HCkStringBuilderW sbRequestBody;
HCkStringBuilderW sbResponseBody;
int respStatusCode;
HCkJsonObjectW jsonResponse;
const wchar_t *errorCode;
const wchar_t *errorDescription;
const wchar_t *requestID;
int i;
int count_i;
const wchar_t *fileName;
rest = CkRestW_Create();
// URL: https://testws.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequestList?username=Utente&password=Password
bTls = TRUE;
port = 443;
bAutoReconnect = TRUE;
success = CkRestW_Connect(rest,L"testws.fatturazioneelettronica.aruba.it",port,bTls,bAutoReconnect);
if (success != TRUE) {
wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
return;
}
// See the Online Tool for Generating JSON Creation Code
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"userName",L"Utente");
CkJsonObjectW_UpdateString(json,L"password",L"Password");
CkJsonObjectW_UpdateString(json,L"userID",L"Utente");
CkJsonObjectW_UpdateString(json,L"comunicationType",L"LI");
CkJsonObjectW_UpdateString(json,L"dataFile",L"dGVzdA==");
CkRestW_AddHeader(rest,L"Content-Type",L"application/json;charset=UTF-8");
CkRestW_AddHeader(rest,L"Accept",L"application/json");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
sbResponseBody = CkStringBuilderW_Create();
success = CkRestW_FullRequestSb(rest,L"POST",L"/services/ClientRequest/CreateTransmissionRequestList?username=Utente&password=Password",sbRequestBody,sbResponseBody);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRestW_getResponseStatusCode(rest);
if (respStatusCode >= 400) {
wprintf(L"Response Status Code = %d\n",respStatusCode);
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkRestW_responseHeader(rest));
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbResponseBody));
CkRestW_Dispose(rest);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jsonResponse = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);
// See the Online Tool for Generating JSON Parse Code
errorCode = CkJsonObjectW_stringOf(jsonResponse,L"errorCode");
errorDescription = CkJsonObjectW_stringOf(jsonResponse,L"errorDescription");
requestID = CkJsonObjectW_stringOf(jsonResponse,L"requestID");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"requestIDList");
while (i < count_i) {
CkJsonObjectW_putI(jsonResponse,i);
fileName = CkJsonObjectW_stringOf(jsonResponse,L"requestIDList[i].fileName");
requestID = CkJsonObjectW_stringOf(jsonResponse,L"requestIDList[i].requestID");
i = i + 1;
}
CkRestW_Dispose(rest);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jsonResponse);
}
{
"errorCode": "",
"errorDescription": "",
"requestID": "YWWCED5QWHU7AQGL",
"requestIDList": [
{
"fileName": "ITADFSREETDSD_LI_0001.xml",
"requestID": "4LMW5CCCBLXKS522"
},
{
"fileName": "ITADFSREETDSD_LI_0002.xml",
"requestID": "62LXGBLXJCDEAX3M"
},
{
"fileName": "ITADFSREETDSD_LI_0003.xml",
"requestID": "GBJDXIYJSWMRKQBP"
}
]
}