Objective-C Fatturazione Elettronica Aruba IT: Upload Invoice Signed

Back to Index

Questo metodo deve essere utilizzato dall’OE per effettuare l’invio di una fattura nel formato XML e già firmata digitalmente secondo norme AGID, ovvero con estension .p7m e formato CAdES-BES (CMS Advanced Electronic Signatures).

Documentation: https://fatturazioneelettronica.aruba.it/apidoc/docs.html#_upload_invoice_signed

CURL Command

curl -X POST  https://demows.fatturazioneelettronica.aruba.it/services/invoice/uploadSigned \
-H 'Accept: application/json' \
-H 'Content-Type: application/json;charset=UTF-8' \
-H 'Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=' \
-d '{
  "dataFile" : "dGVzdA=="
}'

Objective-C Example

#import <CkoRest.h>
#import <CkoJsonObject.h>
#import <CkoStringBuilder.h>
#import <NSString.h>

CkoRest *rest = [[CkoRest alloc] init];
BOOL success;

//  URL: https://demows.fatturazioneelettronica.aruba.it/services/invoice/uploadSigned
BOOL bTls = YES;
int port = 443;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"demows.fatturazioneelettronica.aruba.it" port: [NSNumber numberWithInt: port] tls: bTls autoReconnect: bAutoReconnect];
if (success != YES) {
    NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
    NSLog(@"%@",rest.LastErrorText);
    return;
}

//  See the Online Tool for Generating JSON Creation Code
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"dataFile" value: @"dGVzdA=="];

[rest AddHeader: @"Content-Type" value: @"application/json;charset=UTF-8"];
[rest AddHeader: @"Authorization" value: @"Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE="];
[rest AddHeader: @"Accept" value: @"application/json"];

CkoStringBuilder *sbRequestBody = [[CkoStringBuilder alloc] init];
[json EmitSb: sbRequestBody];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestSb: @"POST" uriPath: @"/services/invoice/uploadSigned" requestBody: sbRequestBody responseBody: sbResponseBody];
if (success != YES) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

int respStatusCode = [rest.ResponseStatusCode intValue];
if (respStatusCode >= 400) {
    NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
    NSLog(@"%@",@"Response Header:");
    NSLog(@"%@",rest.ResponseHeader);
    NSLog(@"%@",@"Response Body:");
    NSLog(@"%@",[sbResponseBody GetAsString]);
    return;
}

CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse LoadSb: sbResponseBody];

//  See the Online Tool for Generating JSON Parse Code
NSString *errorCode = 0;
NSString *errorDescription = 0;
NSString *uploadFileName = 0;

errorCode = [jsonResponse StringOf: @"errorCode"];
errorDescription = [jsonResponse StringOf: @"errorDescription"];
uploadFileName = [jsonResponse StringOf: @"uploadFileName"];

Sample JSON Response Body

{
  "errorCode": "",
  "errorDescription": "",
  "uploadFileName": "IT00499202641_kwefc.xml.p7m"
}