POST | /errors/ | Save error to log |
---|
<?php namespace dtos;
use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};
class ErrorQueryResponse implements JsonSerializable
{
public function __construct(
/** @var string */
public string $CompanyId='',
/** @var int */
public int $Id=0,
/** @var string|null */
public ?string $ExceptionName=null,
/** @var string|null */
public ?string $ExceptionMessage=null,
/** @var string|null */
public ?string $ExceptionSource=null,
/** @var string|null */
public ?string $InnerExceptionName=null,
/** @var string|null */
public ?string $StackTrace=null,
/** @var string|null */
public ?string $URL=null,
/** @var string|null */
public ?string $LoggedInUser=null,
/** @var bool|null */
public ?bool $Visible=null,
/** @var string|null */
public ?string $IPAddress=null,
/** @var DateTime */
public DateTime $CreatedDate=new DateTime(),
/** @var string|null */
public ?string $Request=null,
/** @var string|null */
public ?string $Session=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['ExceptionName'])) $this->ExceptionName = $o['ExceptionName'];
if (isset($o['ExceptionMessage'])) $this->ExceptionMessage = $o['ExceptionMessage'];
if (isset($o['ExceptionSource'])) $this->ExceptionSource = $o['ExceptionSource'];
if (isset($o['InnerExceptionName'])) $this->InnerExceptionName = $o['InnerExceptionName'];
if (isset($o['StackTrace'])) $this->StackTrace = $o['StackTrace'];
if (isset($o['URL'])) $this->URL = $o['URL'];
if (isset($o['LoggedInUser'])) $this->LoggedInUser = $o['LoggedInUser'];
if (isset($o['Visible'])) $this->Visible = $o['Visible'];
if (isset($o['IPAddress'])) $this->IPAddress = $o['IPAddress'];
if (isset($o['CreatedDate'])) $this->CreatedDate = JsonConverters::from('DateTime', $o['CreatedDate']);
if (isset($o['Request'])) $this->Request = $o['Request'];
if (isset($o['Session'])) $this->Session = $o['Session'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->ExceptionName)) $o['ExceptionName'] = $this->ExceptionName;
if (isset($this->ExceptionMessage)) $o['ExceptionMessage'] = $this->ExceptionMessage;
if (isset($this->ExceptionSource)) $o['ExceptionSource'] = $this->ExceptionSource;
if (isset($this->InnerExceptionName)) $o['InnerExceptionName'] = $this->InnerExceptionName;
if (isset($this->StackTrace)) $o['StackTrace'] = $this->StackTrace;
if (isset($this->URL)) $o['URL'] = $this->URL;
if (isset($this->LoggedInUser)) $o['LoggedInUser'] = $this->LoggedInUser;
if (isset($this->Visible)) $o['Visible'] = $this->Visible;
if (isset($this->IPAddress)) $o['IPAddress'] = $this->IPAddress;
if (isset($this->CreatedDate)) $o['CreatedDate'] = JsonConverters::to('DateTime', $this->CreatedDate);
if (isset($this->Request)) $o['Request'] = $this->Request;
if (isset($this->Session)) $o['Session'] = $this->Session;
return empty($o) ? new class(){} : $o;
}
}
class CreateError implements ICompany, JsonSerializable
{
public function __construct(
/** @description The company id, if empty will use the company id for the user you are logged in with. */
// @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
/** @var string|null */
public ?string $CompanyId=null,
/** @description */
// @ApiMember(Description="", IsRequired=true)
/** @var string */
public string $ExceptionName='',
/** @description */
// @ApiMember(Description="", IsRequired=true)
/** @var string */
public string $ExceptionMessage='',
/** @description */
// @ApiMember(Description="")
/** @var string|null */
public ?string $ExceptionSource=null,
/** @description */
// @ApiMember(Description="", IsRequired=true)
/** @var string */
public string $InnerExceptionName='',
/** @description */
// @ApiMember(Description="", IsRequired=true)
/** @var string */
public string $StackTrace='',
/** @description */
// @ApiMember(Description="", IsRequired=true)
/** @var string */
public string $URL='',
/** @description */
// @ApiMember(Description="")
/** @var string|null */
public ?string $LoggedInUser=null,
/** @description */
// @ApiMember(Description="")
/** @var string|null */
public ?string $IPAddress=null,
/** @description */
// @ApiMember(Description="")
/** @var string|null */
public ?string $Request=null,
/** @description */
// @ApiMember(Description="")
/** @var string|null */
public ?string $Session=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['ExceptionName'])) $this->ExceptionName = $o['ExceptionName'];
if (isset($o['ExceptionMessage'])) $this->ExceptionMessage = $o['ExceptionMessage'];
if (isset($o['ExceptionSource'])) $this->ExceptionSource = $o['ExceptionSource'];
if (isset($o['InnerExceptionName'])) $this->InnerExceptionName = $o['InnerExceptionName'];
if (isset($o['StackTrace'])) $this->StackTrace = $o['StackTrace'];
if (isset($o['URL'])) $this->URL = $o['URL'];
if (isset($o['LoggedInUser'])) $this->LoggedInUser = $o['LoggedInUser'];
if (isset($o['IPAddress'])) $this->IPAddress = $o['IPAddress'];
if (isset($o['Request'])) $this->Request = $o['Request'];
if (isset($o['Session'])) $this->Session = $o['Session'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->ExceptionName)) $o['ExceptionName'] = $this->ExceptionName;
if (isset($this->ExceptionMessage)) $o['ExceptionMessage'] = $this->ExceptionMessage;
if (isset($this->ExceptionSource)) $o['ExceptionSource'] = $this->ExceptionSource;
if (isset($this->InnerExceptionName)) $o['InnerExceptionName'] = $this->InnerExceptionName;
if (isset($this->StackTrace)) $o['StackTrace'] = $this->StackTrace;
if (isset($this->URL)) $o['URL'] = $this->URL;
if (isset($this->LoggedInUser)) $o['LoggedInUser'] = $this->LoggedInUser;
if (isset($this->IPAddress)) $o['IPAddress'] = $this->IPAddress;
if (isset($this->Request)) $o['Request'] = $this->Request;
if (isset($this->Session)) $o['Session'] = $this->Session;
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /errors/ HTTP/1.1
Host: api.bokamera.se
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<CreateError xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
<CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
<ExceptionMessage>String</ExceptionMessage>
<ExceptionName>String</ExceptionName>
<ExceptionSource>String</ExceptionSource>
<IPAddress>String</IPAddress>
<InnerExceptionName>String</InnerExceptionName>
<LoggedInUser>String</LoggedInUser>
<Request>String</Request>
<Session>String</Session>
<StackTrace>String</StackTrace>
<URL>String</URL>
</CreateError>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <ErrorQueryResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos"> <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId> <CreatedDate>0001-01-01T00:00:00</CreatedDate> <ExceptionMessage>String</ExceptionMessage> <ExceptionName>String</ExceptionName> <ExceptionSource>String</ExceptionSource> <IPAddress>String</IPAddress> <Id>0</Id> <InnerExceptionName>String</InnerExceptionName> <LoggedInUser>String</LoggedInUser> <Request>String</Request> <Session>String</Session> <StackTrace>String</StackTrace> <URL>String</URL> <Visible>false</Visible> </ErrorQueryResponse>