Inhalte aufrufen

Profilbild

Web-api Upload Images


  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
9 Antworten zu diesem Thema

#1 balex

balex

    Newbie

  • Members
  • Punkt
  • 6 Beiträge

Geschrieben: 01 December 2020 - 10:28

Good Morning, 

 

I develop a command line client for web-api in python , everything works fine for all methods ( GET, PUT, PATCH, POST, DELETE) with normal data ( MD5, Digest and Authentication ), but with multipart form i have issue to authenticate, I receive this : 

 

header: Cache-Control: no-cache

header: Pragma: no-cache

header: Expires: -1

header: Server: Microsoft-IIS/8.5

header: WWW-Authenticate: SmNetHmac1

header: SmartStore-Net-Api-AppVersion: 4.0.0.0

header: SmartStore-Net-Api-Version: 1 4.0.0

header: SmartStore-Net-Api-MaxTop: 120

header: SmartStore-Net-Api-Date: 2020-11-30T15:48:18.6969833Z

header: SmartStore-Net-Api-HmacResultId: 9

header: SmartStore-Net-Api-HmacResultDesc: ContentMd5NotMatching

header: X-AspNet-Version: 4.0.30319

header: Set-Cookie: SMARTSTORE.VISITOR=409ba4bb-6e56-4096-8db7-0cc90fb1f65a; expires=Tue, 30-Nov-2021 15:48:18 GMT; path=/; HttpOnly

header: X-Powered-By: ASP.NET

header: Date: Mon, 30 Nov 2020 15:48:18 GMT

header: Content-Length: 0

 

Python version 3.7.9

requests version 2.24.0

 

Someone have idea how construct correctly the message representation with MD5 hashed content ?

 

Thanks for any help

Best Regards

 



#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3799 Beiträge

Geschrieben: 01 December 2020 - 15:33

ContentMd5NotMatching says that the MD5 hash transmitted by Content-Md5 header is wrong (not the message representation).
I don't know if it helps in context of Python but here are some links how the Smartstore C# API client calculates it:
 
 

Marcus Gesing

Smartstore AG


#3 balex

balex

    Newbie

  • Members
  • Punkt
  • 6 Beiträge

Geschrieben: 02 December 2020 - 04:49

Thank you Marcus for the reply, I checked the C# code, but I made already the same code in my Python function/classes, 

and in fact work well with others http methods, put, patch and post .. but without sending the multipart data, I think is something 

else and I can't figure out what it is :)



#4 balex

balex

    Newbie

  • Members
  • Punkt
  • 6 Beiträge

Geschrieben: 02 December 2020 - 05:41

Ok, I figured out a step forward, I was converting to string the multipart object not only for computing the MD5 but also on post send data, now I moved this 

conversion directly inside the MD5 function and the post send work.

 

But now I get a different error : 

 

('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))

 

the image is only 10k and my multipart object preparation is : 

 

m = MultipartEncoder(
fields={
'Id': '1339',
'files': ('filename', open('image.jpg', 'rb'), 'image/jpg')
}
)
 


#5 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3799 Beiträge

Geschrieben: 02 December 2020 - 10:48

That sounds like a Python client error, that unfortunately tells me nothing. On the basis of the exact HTTP response and headers it might be possible to say more.


  • stefanmueller gefällt das

Marcus Gesing

Smartstore AG


#6 balex

balex

    Newbie

  • Members
  • Punkt
  • 6 Beiträge

Geschrieben: 02 December 2020 - 15:30

There is any difference on between Smartstore.NET version 4.0 and 4.1 ?

I read there is a new Media Library api in 4.1 right ? 



#7 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3799 Beiträge

Geschrieben: 03 December 2020 - 01:21

Yes, OData v4 support and media endpoints.


Marcus Gesing

Smartstore AG


#8 balex

balex

    Newbie

  • Members
  • Punkt
  • 6 Beiträge

Geschrieben: 03 December 2020 - 06:50

But the documentation is still 4.0 on website ? There is any place to read the 4.1 documentation and new Media endpoints documentation ?


  • stefanmueller gefällt das

#9 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3799 Beiträge

Geschrieben: 03 December 2020 - 10:46

No, as mentioned in the linked blog post. The interactive Swagger documentation is incomplete at the moment due to an outdated component.
We have to wait until porting to ASP.NET Core to be able to update the component and complete the documentation.
 
The static documentation is more intended for all non-endpoint related documentations like API authentication etc.

Marcus Gesing

Smartstore AG


#10 balex

balex

    Newbie

  • Members
  • Punkt
  • 6 Beiträge

Geschrieben: 03 December 2020 - 11:11

Yeah,  I see, i have an online customer with 4.0 and my ( for example .. get method work fine )  but my local development installation with 4.1 give me bad header on authentication ... 

 

so you definitely have some issue with documentation