I want to get embedded image from WordPress Rest api with my posts. I find out that i should add _embed or _embed=true as query param with my request. Result have extra _embedded part like this: enter image description here I put embeddedDto with name _embedded in main json file and create other needed Dtos to handle this.

It seems had problem with highlighted point in image wp:featuremedia, how i should parse it to json? I create a class wp that have featuremedia dto. Am i right or not? you can see other Dtos here:

public class EmbeddedDto implements Serializable{

    private WPDto wp;

    public WPDto getWp() {
        return wp;

    public void setWp(WPDto wp) {
        this.wp = wp;


and this:

public class WPDto implements Serializable {

    private List<MediaDto> featuremedia;

    public List<MediaDto> getFeaturemedia() {
        return featuremedia;

    public void setFeaturemedia(List<MediaDto> featuremedia) {
        this.featuremedia = featuremedia;


and finally:

public class MediaDto implements Serializable {

    private Long id;
    private String date;
    private String slug;
    private String link;
    private String title;
    private String source_url;

But wp is always null.

  • it is probably not realistic to expect anyone here to have java knowledge, but the error seems to be obvious, you expect tile to be a string while it is an object – Mark Kaplun Apr 3 '18 at 7:44
  • 2
    I don't understand what you mean. REST API responses are already in json format. The error says it is expected a string instead of an object, so may you just need to use $[0]._embedded.wp:featuredmedia[0].title.rendered (a string) instead of $[0]._embedded.wp:featuredmedia[0].title (an object). – cybmeta Apr 3 '18 at 7:51
  • Ok i will update the question – Kenji Apr 3 '18 at 7:53
  • dear @MarkKaplun I think I find the answer and it was java trick to handle and pars some json like that, but do not know to answer my question so may it will use-full for some other people or just delete the question? what do you suggest? – Kenji Apr 3 '18 at 7:56
  • Answer it, it could be helpful for others. – cybmeta Apr 3 '18 at 8:10

The problem was with parsing wp:featuremedia:. I handle this with @SerializedName. Instead of creating class wp that contains featuremedia,named all to wp:featuredmedia

public class EmbeddedDto implements Serializable{
    private List<MediaDto> featuremedia;

Now Json parses in right way.

Not the answer you're looking for? Browse other questions tagged or ask your own question.