Login to website
Posted: Fri Sep 06, 2019 8:36 am
Does anyone know how to login to a website using a username and password?
Thanks
Tom
Thanks
Tom
Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
http://mail.hmgforum.com/
Hi Tom.tomtagaris wrote: ↑Fri Sep 06, 2019 11:33 am :the website is from the Ministry of Finance and was on trial for importing invoices but released when it is spring again i will definitely thanks for your help
https://mydata-dev.portal.azure-api.net ... ndinvoices?
Code: Select all
#include "hmg.ch"
Function Main
cSampleInvXML:= '<?xml version="1.0" encoding="utf-8"?>' + ;
'<InvoicesDoc>' + ;
' <invoice>' + ;
' <uid>str1234</uid>' + ;
' <mark>str1234</mark>' + ;
' <issuer>' + ;
' <vatNumber>str1234</vatNumber>' + ;
' <country>AD</country>' + ;
' <name>str1234</name>' + ;
' <address>' + ;
' <street>str1234</street>' + ;
' <number>str1234</number>' + ;
' <postalCode>str1234</postalCode>' + ;
' <city>str1234</city>' + ;
' </address>' + ;
' </issuer>' + ;
' <counterpart>' + ;
' <vatNumber>str1234</vatNumber>' + ;
' <country>AD</country>' + ;
' <name>str1234</name>' + ;
' <address>' + ;
' <street>str1234</street>' + ;
' <number>str1234</number>' + ;
' <postalCode>str1234</postalCode>' + ;
' <city>str1234</city>' + ;
' </address>' + ;
' </counterpart>' + ;
' <invoiceHeader>' + ;
' <branch>123</branch>' + ;
' <series>str1234</series>' + ;
' <aa>12345</aa>' + ;
' <issueDate>2012-12-13</issueDate>' + ;
' <invoiceType>1.1</invoiceType>' + ;
' <vatPaymentSuspension>true</vatPaymentSuspension>' + ;
' <currency>AED</currency>' + ;
' <exchangeRate>123.45</exchangeRate>' + ;
' <correlatedInvoices>str1234</correlatedInvoices>' + ;
' <selfPricing>true</selfPricing>' + ;
' <dispatchDate>2012-12-13</dispatchDate>' + ;
' <dispatchTime>12:12:12</dispatchTime>' + ;
' <vehicleNumber>str1234</vehicleNumber>' + ;
' <movePurpose>str1234</movePurpose>' + ;
' </invoiceHeader>' + ;
' <invoiceDetails>' + ;
' <lineNumber>123</lineNumber>' + ;
' <quantity>123.45</quantity>' + ;
' <measurementUnit>123</measurementUnit>' + ;
' <invoiceDetailType>123</invoiceDetailType>' + ;
' <netValue>123.45</netValue>' + ;
' <vatCategory>123</vatCategory>' + ;
' <vatExemptionCategory>123</vatExemptionCategory>' + ;
' <dienergia>' + ;
' <applicationId>str1234</applicationId>' + ;
' <applicationDate>2012-12-13</applicationDate>' + ;
' <doy>str1234</doy>' + ;
' <shipId>str1234</shipId>' + ;
' </dienergia>' + ;
' <discountOption>true</discountOption>' + ;
' <withheldAmount>123.45</withheldAmount>' + ;
' <withheldPercentCategory>123</withheldPercentCategory>' + ;
' <stampDutyPercentCategory>123</stampDutyPercentCategory>' + ;
' <feesAmount>123.45</feesAmount>' + ;
' <feesPercentCategory>123</feesPercentCategory>' + ;
' <otherTaxesPercentCategory>123</otherTaxesPercentCategory>' + ;
' <otherTaxesAmount>123.45</otherTaxesAmount>' + ;
' <deductionsPercentage>123.45</deductionsPercentage>' + ;
' <incomeClassification>' + ;
' <classificationType>123</classificationType>' + ;
' <classificationCategory>123</classificationCategory>' + ;
' <amount>123.45</amount>' + ;
' </incomeClassification>' + ;
' </invoiceDetails>' + ;
' <invoiceSummary>' + ;
' <totalNetValue>123.45</totalNetValue>' + ;
' <totalVatAmount>123.45</totalVatAmount>' + ;
' <totalWithheldAmount>123.45</totalWithheldAmount>' + ;
' <totalFeesAmount>123.45</totalFeesAmount>' + ;
' <totalStampDutyAmount>123.45</totalStampDutyAmount>' + ;
' <totalOtherTaxesAmount>123.45</totalOtherTaxesAmount>' + ;
' <totalDeductionsAmount>123.45</totalDeductionsAmount>' + ;
' <totalGrossValue>123.45</totalGrossValue>' + ;
' <incomeClassification>' + ;
' <classificationType>123</classificationType>' + ;
' <classificationCategory>123</classificationCategory>' + ;
' <amount>123.45</amount>' + ;
' </incomeClassification>' + ;
' </invoiceSummary>' + ;
' </invoice>' + ;
'</InvoicesDoc>'
Msginfo( cSampleInvXML )
AADE_Invoice ( cSampleInvXML )
RETURN
*************************************************************************************
Function AADE_Invoice ( cInvoice_XML )
Local cUserId := "1234" //user id
Local cSubscriptionKey := "abcdefghijkl" //Subscription key which provides access to this API
Local responseHttp:= "", hResponse := {=>}
Local oHttp:= ""
Local cUrl := "https://mydata-dev.azure-api.net/SendInvoices"
BEGIN SEQUENCE WITH {|o| break(o)}
oHttp := Win_OleCreateObject( "MSXML2.ServerXMLHTTP" )
RECOVER USING oErr
MsgStop( oErr:Description, "Error Microsoft XML Core Services (MSXML)" )
oHttp:=""
END SEQUENCE
IF EMPTY(oHttp)
MsgStop ("Error while initializing MSXML" )
RETURN
ENDIF
BEGIN SEQUENCE WITH {|o| break(o)}
ohttp:Open( "POST", cUrl, .F. )
ohttp:setRequestHeader("Content-Type", "text/xml")
ohttp:setRequestHeader("aade-user-id", cUserId) //User Id
ohttp:setRequestHeader("Ocp-Apim-Subscription-Key", cSubscriptionKey) // Subscription key which provides access to this API. Found in your Profile.
//send your XML with invoices
ohttp:Send( cInvoice_XML )
responseHttp := ohttp:ResponseBody() //response from server
RECOVER USING oErr
responseHttp := ""
MsgStop( oErr:Description ,"Error" )
END SEQUENCE
Msgdebug( responseHttp )
hb_jsonDecode ( responseHttp, @hResponse )
Msgdebug ( hResponse )
Msgdebug ("Status code: " ,hb_HGet ( hResponse, "statusCode" ) )
Msgdebug ("Message: " , hb_HGet ( hResponse, "message" ) )
RETURN
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<InvoicesDoc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.aade.gr/myDATA/invoice/v1.0 schema.xsd" xmlns="http://www.aade.gr/myDATA/invoice/v1.0">
<!-- 1st invoice -->
<invoice>
<uid>string</uid>
<mark>string</mark>
<issuer>(...)</issuer>
<counterpart>(...)</counterpart>
<invoiceHeader>(...)</invoiceHeader>
<invoiceDetails>(...)</invoiceDetails>
(...)
<invoiceDetails>(...)</invoiceDetails>
<invoiceSummary>(...)</invoiceSummary>
</invoice>
<!-- 2nd invoice -->
<invoice>
<uid>string</uid>
<mark>string</mark>
<issuer>(...)</issuer>
<counterpart>(...)</counterpart>
<invoiceHeader>(...)</invoiceHeader>
<invoiceDetails>(...)</invoiceDetails>
(...)
<invoiceDetails>(...)</invoiceDetails>
<invoiceSummary>(...)</invoiceSummary>
</invoice>
(...)
<!-- n-th invoice -->
<invoice>
<uid>string</uid>
<mark>string</mark>
<issuer>(...)</issuer>
<counterpart>(...)</counterpart>
<invoiceHeader>(...)</invoiceHeader>
<invoiceDetails>(...)</invoiceDetails>
(...)
<invoiceDetails>(...)</invoiceDetails>
<invoiceSummary>(...)</invoiceSummary>
</invoice>
</InvoicesDoc>