简体   繁体   中英

HTTP response shows Accept=multipart/form-data BUT not setting this header and settting CamelAcceptContentType, “application/json”

I am not settng the Accept=multipart/form-data in the REQUEST, I am setting the exchange.getIn().setHeader("CamelAcceptContentType", "application/json"); and exchange.getIn().setHeader("Content-Type", "application/json");

the RESPONSE is Accept=multipart/form-data CamelHttpMethod=POST, CamelHttpResponseCode=415, CamelHttpResponseText=Unsupported Media Type

It appears the server is telling me it is sending me back a multipart form-data media type, but, I'm telling it I am looking for application/json.

I am not sending multi-part form-data in request. can someone explain what is going on here? thank you! is the server setting this?

StringBuilder authHeader = new StringBuilder("Bearer ");
authHeader.append(token);
LOG.info("Authorization: " + authHeader.toString());

exchange.setProperty("CamelCharsetName", "UTF-8");  //"CamelCharsetName" Exchange.CHARSET_NAME
exchange.getIn().setHeader("CamelHttpCharacterEncoding", "UTF-8");   //"CamelHttpCharacterEncoding" Exchange.HTTP_CHARACTER_ENCODING
exchange.getIn().setHeader("CamelAcceptContentType", "application/json");  //"CamelAcceptContentType" Exchange.ACCEPT_CONTENT_TYPE
exchange.getIn().setHeader("CamelHttpUri", uploadUrl);  //"CamelHttpUri" Exchange.HTTP_URI
exchange.getIn().setHeader("CamelHttpMethod", "POST");  //"CamelHttpMethod" Exchange.HTTP_METHOD
exchange.getIn().setHeader("x-ge-csvformat", "ODB");
exchange.getIn().setHeader("Tenant", tenant);
exchange.getIn().setHeader("Content-Type", "application/json"); // for JSON ONLY comment for CSV
exchange.getIn().setHeader("Authorization", authHeader.toString());

I guess the question should be WHY am I getting a response header with Accept = multipart/form-data ? when I am not setting or using multipart/form-data?

HERE IS The http Post request.

        setHeader[CamelHttpMethod, POST] --> 
    http4://apm-ts-query-svc-prod.app-api.aws-usw02-pr.px.io:443/v2/ts/upload?throwExceptionOnFailure=false <<< Pattern:InOnly, 
    Headers:{Authorization=Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImxlZ2FjeS10b2tlbi1rZXkiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiI0Zrzfo6VKOA, 
    breadcrumbId=ID-alfuse2i-35498-1557318510555-3-598, CamelAcceptContentType=application/json, CamelFileAbsolute=false, 
CamelFileAbsolutePath=/app/PassThruMT1/jboss-fuse-6.3.0.redhat-310/g-dig/upload/Industries/J402_Motor_2019-05-02-11-00-00_0.csv, CamelFileLastModified=1557319009000, CamelFileLength=1538, 
CamelFileName=Industries/J_Motor_2019-05-02-11-00-00_0.csv, 
CamelFileNameConsumed=Industries/J_Motor_2019-05-02-11-00-00_0.csv, 
CamelFileNameOnly=J_Motor_2019-05-02-11-00-00_0.csv, CamelFileNameProduced=g-dig/json/Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelFileParent=g-d/upload/Industries, CamelFilePath=g-dal/upload/Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelFileRelativePath=Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelHttpCharacterEncoding=UTF-8, 
CamelHttpMethod=POST, 
CamelHttpUri=https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload?throwExceptionOnFailure=false, 
Content-Type=application/json, CUSTKEY=Industries, EXPIRY=2019-05-09 06:36:36.101, TENANT=676f31-752-40d-81-c80c5be, TOKEN=eyJhbGciOiJSUzI1NiIsImtpZeQ2eflqE5C3j44MvhPIR0bSEZgznonA503vrzfo6VKOA, UPLOADURL=https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload, x-ge-csvformat=ODB}, BodyType:String, Body:{
          "tags" : [ {
            "tagId" : "TI5925.PV",
            "data" : [ {
              "ts" : "2019-05-02T16:00:00",
              "v" : "8.903611",
              "q" : "3"
            } ]
          }, {
            "tagId" : "TIA4562.PV",
            "data" : [ {
              "ts" : "2019-05-02T16:00:00",
              "v" : "56.47153",
              "q" : "3"
            } ]
          }, {
            "tagId" : "XIA4596A.PV",
            "data" : [ {
              "ts" : "2019-05-02T16:00:00",
              "v" : "3.335917",
              "q" : "3"
            } ]
          }, {
            "tagId" : "XIA4596B.PV",
            "data" : [ {
              "ts" : "2019-05-02T16:00:00",
              "v" : "1.670584",
              "q" : "3"
            } ]
          }, {
            "tagId" : "TIA4561.PV",
            "data" : [ {
              "ts" : "2019-05-02T16:00:00",
              "v" : "49.85203",
              "q" : "3"
            } ]
          }, {
            "tagId" : "XIA4595A.PV",
            "data" : [ {
              "ts" : "2019-05-02T16:00:00",
              "v" : "2.098929",
              "q" : "3"
            } ]
          }, {
            "tagId" : "XIA4595B.PV",
            "data" : [ {
              "ts" : "2019-05-02T16:00:00",
              "v" : "2.647079",
              "q" : "3"
            } ]
          }, {
            "tagId" : "TIA4565.PV",
        ... [Body clipped after 1000 chars, total length is 16321]

AND HERE IS THE SERVER RESPONSE - NOTICE at beginning of response message the Accept=multipart/form=data.

     log[HTTP4 Upload Response: ${body}] <<< Pattern:InOnly, Headers:{Accept=multipart/form-data, Authorization=Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImxlZ2FjeS10b2tlbi1rZXkiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiI0ZmYwY2UxZGFhN2E0N2U4ODIwA503vrzfo6VKOA, breadcrumbId=ID-alphprdfuse2i-35498-1557318510555-3-598, Cache-Control=no-cache, no-store, max-age=0, must-revalidate, 
    CamelAcceptContentType=application/json, 
    CamelFileAbsolute=false, CamelFileAbsolutePath=/app/PassMT1/jboss-fuse-6.3.0.redhat-310/tal/upload/Industries/J_Motor_2019-05-02-11-00-00_0.csv,
 CamelFileLastModified=1557319009000, CamelFileLength=1538,
 CamelFileName=Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelFileNameConsumed=Industries/J_Motor_2019-05-02-11-00-00_0.csv,
 CamelFileNameOnly=J_Motor_2019-05-02-11-00-00_0.csv, 
CamelFileNameProduced=g-dal/json/Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelFileParent=g-dal/upload/Industries, 
CamelFilePath=g-dal/upload/Industries/J_Motor_2019-05-02-11-00-00_0.csv, 
CamelFileRelativePath=Industries/J_Motor_2019-05-02-11-00-00_0.csv, 
CamelHttpCharacterEncoding=UTF-8, CamelHttpMethod=POST, 
CamelHttpResponseCode=415, CamelHttpResponseText=Unsupported Media Type, 
CamelHttpUri=https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload?throwExceptionOnFailure=false, Connection=keep-alive, 
Content-Length=0, Corr=4c4ffcb10fa7ef1c, CUSTKEY=Industries, 
Date=Wed, 08 May 2019 12:38:27 GMT, Expires=0, EXPIRY=2019-05-09 06:36:36.101, Pragma=no-cache, Server=none, Strict-Transport-Security=max-age=31536000 ; includeSubDomains, TENANT=67626f31-75-43-81b-cc5bdbce, TOKEN=eyJhbGciOiJSUzI1NiIsI6GlLIGp8-HPeQ2eflqE5C3j44MvhPIR0bSEZgznonA503vrzfo6VKOA, UPLOADURL=https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload, X-Application-Context=APMTS:cloud:0, X-Content-Type-Options=nosniff, X-Frame-Options=DENY, x-ge-csvformat=ODB, X-Vcap-Request-Id=01d04cf7-47ae-4cf9-7d4c-357afe207769, X-Xss-Protection=1; mode=block}, BodyType:org.apache.camel.converter.stream.InputStreamCache, Body:[Body is instance of org.apache.camel.StreamCache]

ok, this turned out to be the mechanics of the cloud environment configuration.

the Server URL had 2 endpoints, 1 for multipart form-data and 1 for JSON. I was posting to the CSV multipart form-data.

https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload - CSV multipart https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts - JSON

So, the answer is yes, in that the servers response is letting me know what it is expecting or able to communicate in. Learning... is fun - thanks !!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM