hildogjr / KiCost

Build cost spreadsheet for a KiCad project.
MIT License
493 stars 97 forks source link

API TME change #534

Closed prasetekus closed 1 year ago

prasetekus commented 1 year ago

Just to inform the development team I received following e-mail from TME last week:

Dear Sir/Madam, We would like to inform you that we are introducing the format of the submitted headers in API requests: Content-Type: application/x-www-form-urlencoded All queries that do not meet this requirement will be rejected. Please adjust your queries. If you have any questions, please contact us developers@tme.eu Greetings TME

I do not know, when the change should come into effect and how it will affect KiCost implementation for TME API, but I sense some troubles in near future :-)

set-soft commented 1 year ago

Hi @prasetekus ! First: thanks for posting this. I think TME already supports it, the news seems to be that they will only support it. The current code is:

        data = do_encode(urlencode(params))
        headers = {"Content-type": "application/x-www-form-urlencoded"}
        return Request(url, data, headers)

So we are using urlencode to encode the parameters and declaring the content as application/x-www-form-urlencoded. So I think we are already using the method that will become mandatory. If you see any problem feel free to open an issue.