Page 1 of 5

Login to website

Posted: Fri Sep 06, 2019 8:36 am
by tomtagaris
Does anyone know how to login to a website using a username and password?
Thanks
Tom

Re: Login to website

Posted: Fri Sep 06, 2019 10:33 am
by mol
Which website?

Re: Login to website

Posted: Fri Sep 06, 2019 11:33 am
by tomtagaris
: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?

Re: Login to website

Posted: Fri Sep 06, 2019 1:07 pm
by edk
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?
Hi Tom.

Based on your link, I prepared a working piece of the program to connect to the indicated method. As you can see (according to the specification) authorization data must be sent in the header.
Of course, you must prepare a valid xml file containing invoices in advance. I included the sample structure of the xml file in the source, based on the indicated https://apimgmtstu2uzdx6cqwpx6k3.blob.c ... c-v0.5.xsd file.

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 

PS. By the way, it's better to try to do it in a test environment rather than a production environment. ;)

Re: Login to website

Posted: Fri Sep 06, 2019 3:27 pm
by tomtagaris
thank you very much
i will try it your help is valuable
thank you very much

Re: Login to website

Posted: Mon Sep 09, 2019 11:19 am
by tomtagaris
ι uses the code and logged in with the site and I get these errors
what can I do
bug.png
bug.png (322.23 KiB) Viewed 1153 times

Re: Login to website

Posted: Tue Sep 10, 2019 12:39 pm
by edk
The error description indicates that you need to add schema information.

Try adding this information to root XML element, as in the attached xml sample.
invoice.xml and InvoicesDoc-v0.5.xsd.zip
(5.4 KiB) Downloaded 31 times
You can validate your XML file based on the schema definition, e.g. on this page: https://www.freeformatter.com/xml-validator-xsd.html

Re: Login to website

Posted: Wed Sep 11, 2019 10:33 am
by tomtagaris
UNDERSTAND THE PROBLEM AND THANK YOU VERY MUCH
THAT WOULD LIKE A LITTLE HELP EVER
HOW CAN I SEND MORE THAN ONE INVOICE WITH SAME XML FILE TO WEBSITE
THANKS

Re: Login to website

Posted: Wed Sep 11, 2019 11:40 am
by edk
It's simple, each next invoice should be between <invoice> ... </invoice> tags.
Simplified structure:

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>

Re: Login to website

Posted: Fri Sep 13, 2019 5:31 am
by tomtagaris
it's so easy
thank you very much
Something else
how can i get data based on this webpage
https://mydata-dev.portal.azure-api.net ... stinvoices?