Giter Site home page Giter Site logo

No suitable HttpMessageConverter found to read request body into object of type class com.example.demo.entity.client.image.Avatar from request with content type of image/png;charset=UTF-8 about spring-content HOT 8 CLOSED

ddxl123 avatar ddxl123 commented on May 24, 2024
No suitable HttpMessageConverter found to read request body into object of type class com.example.demo.entity.client.image.Avatar from request with content type of image/png;charset=UTF-8

from spring-content.

Comments (8)

paulcwarren avatar paulcwarren commented on May 24, 2024

Hi @ddxl123 , the POST looks wrong to me. You cannot POST content to the avatars collection. You can only POST content to avatar entities. You would need to POST to http://192.168.1.3:8080/avatars/{id} or http://192.168.1.3:8080/avatars/{id}/content (since you added a content property by correlating the attributes)

from spring-content.

ddxl123 avatar ddxl123 commented on May 24, 2024

Hi @ddxl123 , the POST looks wrong to me. You cannot POST content to the avatars collection. You can only POST content to avatar entities. You would need to POST to http://192.168.1.3:8080/avatars/{id} or http://192.168.1.3:8080/avatars/{id}/content (since you added a content property by correlating the attributes)

@paulcwarren
http://192.168.1.3:8080/avatars/1 or http://192.168.1.3:8080/avatars/1/content still the same mistake.

response: {
    "timestamp": "2023-08-16T04:46:57.969+00:00",
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/avatars/1"
}

from spring-content.

paulcwarren avatar paulcwarren commented on May 24, 2024

Perhaps your app is not initializing spring content rest properly. Any chance you can provide a repro-able sample?

Alternatively, I have a working spring-content-fs/rest example here

from spring-content.

paulcwarren avatar paulcwarren commented on May 24, 2024

If you want to debug it you can put a breakpoint in DispatcherServlet.doDispatch and see what handler it is selecting for this request.

from spring-content.

ddxl123 avatar ddxl123 commented on May 24, 2024

I’m not sure what’s going on, but it’s suddenly fine now, but I haven’t changed anything, it’s weird…

from spring-content.

ddxl123 avatar ddxl123 commented on May 24, 2024

If you want to debug it you can put a breakpoint in DispatcherServlet.doDispatch and see what handler it is selecting for this request.

from spring-content.

ddxl123 avatar ddxl123 commented on May 24, 2024

If you want to debug it you can put a breakpoint in DispatcherServlet.doDispatch and see what handler it is selecting for this request.

@paulcwarren
In this case, you must use Content-Type:application/hal+json +POST 192.168.1.3:8080/avatars/1 to request (create this data row), and then use Content-Type:image/png + POST 192.168.1.3:8080/avatars/1 to store it to succeed, if you store it directly, it will appear 404.

I looked at the document tutorial and it seems to be like this. The tutorial in the document is not easy to understand for beginners. You should add emphasis: "You must first [First create an entity]".

from spring-content.

paulcwarren avatar paulcwarren commented on May 24, 2024

Assuming you are using a ContentStore then yes (which is what 99% of users do) then yes the entity has to be created and exist before you can associate and store content with it.

If you look at the valid POST URIs (for content 192.168.1.3:8080/avatars/1 and 192.168.1.3:8080/avatars/1/content) you can see it is an entity-based URI because the content is associated with the entity.

from spring-content.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.