0

I have a springboot rest api. It was working fine but I must have added some dependency to it that has caused it to start returning response in Xml instead of JSON. I have other microservices that are returning json response and I have not done anything consciously to return XML. I need the JSON response. can anybody help.

I am including the dependencies that I have in the gradle file if that helps.

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    // https://mvnrepository.com/artifact/org.modelmapper/modelmapper
    implementation group: 'org.modelmapper', name: 'modelmapper', version: '3.0.0'
    // https://jmaven.com/dependency/org.springframework.boot/spring-boot-starter-validation
    implementation 'org.springframework.boot:spring-boot-starter-validation:2.6.7'
    // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security
    implementation 'org.springframework.boot:spring-boot-starter-security:2.6.7'
    implementation 'org.springframework.boot:spring-boot-starter-amqp'
    // implementation 'org.springframework.cloud:spring-cloud-starter-config'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    implementation 'io.jsonwebtoken:jjwt-api:0.11.2'
    // https://mvnrepository.com/artifact/com.google.code.gson/gson
    implementation group: 'com.google.code.gson', name: 'gson', version: '2.7'
    // https://mvnrepository.com/artifact/org.hashids/hashids
    implementation group: 'org.hashids', name: 'hashids', version: '1.0.3'
    // https://mvnrepository.com/artifact/joda-time/joda-time
    //implementation group: 'joda-time', name: 'joda-time', version: '2.3'
    runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2',
            // Uncomment the next line if you want to use RSASSA-PSS (PS256, PS384, PS512) algorithms:
            //'org.bouncycastle:bcprov-jdk15on:1.60',
            'io.jsonwebtoken:jjwt-jackson:0.11.2'
    // https://mvnrepository.com/artifact/io.springfox/springfox-boot-starter
    implementation 'io.springfox:springfox-boot-starter:3.0.0'
    compileOnly 'org.projectlombok:lombok'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    //runtimeOnly 'mysql:mysql-connector-java'
    runtimeOnly 'org.postgresql:postgresql'
    annotationProcessor 'org.projectlombok:lombok'
    // https://mvnrepository.com/artifact/commons-validator/commons-validator
    implementation group: 'commons-validator', name: 'commons-validator', version: '1.7'
    // https://mvnrepository.com/artifact/com.googlecode.libphonenumber/libphonenumber
    implementation group: 'com.googlecode.libphonenumber', name: 'libphonenumber', version: '8.12.45'
    // https://mvnrepository.com/artifact/javax.mail/mail
    implementation group: 'javax.mail', name: 'mail', version: '1.5.0-b01'
    // https://mvnrepository.com/artifact/org.apache.commons/commons-io
    implementation group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
    // https://mvnrepository.com/artifact/com.mandrillapp.wrapper.lutung/lutung
    //implementation group: 'com.mandrillapp.wrapper.lutung', name: 'lutung', version: '0.0.8'
    // https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk
    implementation group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.12.180'
    // https://mvnrepository.com/artifact/com.twilio.sdk/twilio
    // https://www.twilio.com/docs/libraries/java
    implementation group: "com.twilio.sdk", name: "twilio", version: "8.29.1"
    //implementation 'org.springframework.boot:spring-boot-starter-quartz'
    // https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-openfeign
    implementation 'org.springframework.cloud:spring-cloud-starter-openfeign:3.1.1'

    //implementation 'org.springframework.cloud:spring-cloud-openfeign-dependencies:3.1.1'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
Waqar Sadiq
  • 135
  • 1
  • 9
  • Please check if your question is not a duplicated of [this](https://stackoverflow.com/questions/41036377/spring-mvc-changing-default-response-format-from-xml-to-json) question. – Abilio Castro Apr 25 '22 at 22:44
  • 1
    I wonder if it is an outdated answer. it is 5 years old. I have 5 other microservices and I have not included jackson-databind dependency in any of them and have not defined the converter that he mentions either. The problem is that when I explicitly include the jackson-databind dependency, I get runtime errors because I have to include gson dependency and that does not work nicely with jackson. – Waqar Sadiq Apr 25 '22 at 23:07

1 Answers1

0

It is due to the Twilio library removing that library and using HTTP rest call to use Twilio APIs will solve the problem.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 21 '23 at 16:16