In Swift, this API call returns an invoiceId
return client.post("https://www.szamlazz.hu/szamla/", headers: HTTPHeaders([("Content-Type", "application/json")]), beforeSend: { (req) in
try req.content.encode(["action-xmlagentxmlfile": xml], as: .urlEncodedForm)
}).flatMap { (response) -> EventLoopFuture<Void> in
if response.status == .ok && !response.headers.contains(name: "szlahu_error") {
if vegszamla != true {
p.invoiceCreatedAt = Date()
p.invoiceId = response.headers["szlahu_szamlaszam"].first
but the similar one in TypeScript return null, why? Same content is sent.
const formData = new URLSearchParams()
formData.append('action-xmlagentxmlfile', xml)
const response = await fetch(`https://www.szamlazz.hu/szamla`, {
method: 'POST',
body: formData.toString(),
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
if (
response.status === 200 &&
!response.headers.has('szlahu_error')
) {
const invoiceId = response.headers.get('szlahu_szamlaszam')
if (!invoiceId) {
No error raised.
I tried application/json as content type, same result.
I see this as response:
Response {
[Symbol(realm)]: null,
[Symbol(state)]: {
aborted: false,
rangeRequested: false,
timingAllowPassed: true,
requestIncludesCredentials: true,
type: 'default',
status: 200,
timingInfo: {
startTime: 6905.054625034332,
redirectStartTime: 6905.054625034332,
redirectEndTime: 6966.9528748989105,
postRedirectStartTime: 6966.9528748989105,
finalServiceWorkerStartTime: 0,
finalNetworkResponseStartTime: 0,
finalNetworkRequestStartTime: 0,
endTime: 0,
encodedBodySize: 335,
decodedBodySize: 0,
finalConnectionTimingInfo: null
},
cacheState: '',
statusText: 'OK',
headersList: HeadersList {
cookies: null,
[Symbol(headers map)]: [Map],
[Symbol(headers map sorted)]: null
},
urlList: [ [URL], [URL] ],
body: { stream: undefined }
},
[Symbol(headers)]: HeadersList {
cookies: null,
[Symbol(headers map)]: Map(12) {
'date' => [Object],
'server' => [Object],
'set-cookie' => [Object],
'cache-control' => [Object],
'pragma' => [Object],
'content-type' => [Object],
'expires' => [Object],
'vary' => [Object],
'content-encoding' => [Object],
'content-length' => [Object],
'keep-alive' => [Object],
'connection' => [Object]
},
[Symbol(headers map sorted)]: null
}
}