김종훈
게시글
댓글
감사합니다. content-type과 boundary를 수정하니 정상동작됩니다.
Mail 2019.12.30
boundary에 하이픈을 양쪽에 두개주니까 다시 400 에러로 돌아왔습니다. Request Raw POST https://apis.worksmobile.com/r/**MyAPIID**/mail/v2/sendMail HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36 Authorization: Bearer **My Access Token** consumerKey: **My consumerKey ** Date: Fri, 20 Dec 2019 07:26:13 GMT Content-Type: multipart/mixed; boundary=--8d7856954821f3c--; charset=UTF-8 Host: apis.worksmobile.com Content-Length: 746 Expect: 100-continue Connection: Keep-Alive --8d7856954821f3c-- Content-Disposition: form-data; name="userName" jonghoon --8d7856954821f3c-- Content-Disposition: form-data; name="to" ilms9012@gmail.com --8d7856954821f3c-- Content-Disposition: form-data; name="cc" --8d7856954821f3c-- Content-Disposition: form-data; name="bcc" --8d7856954821f3c-- Content-Disposition: form-data; name="subject" this is subject --8d7856954821f3c-- Content-Disposition: form-data; name="text" this is text --8d7856954821f3c-- Content-Disposition: form-data; name="contentType" html --8d7856954821f3c-- Content-Disposition: form-data; name="saveSentMail" true --8d7856954821f3c-- Content-Disposition: form-data; name="sendSeparately" false --8d7856954821f3c-- 아래는 Response 내역입니다. HTTP/1.1 400 Bad Request Date: Fri, 20 Dec 2019 07:26:13 GMT Server: Apache Strict-Transport-Security: max-age=63072000; includeSubdomains; preload Referrer-Policy: unsafe-url Connection: close Transfer-Encoding: chunked Content-Type: application/json 64 {"code":"INVALID_PARAMETER","domain":"mail","message":"Data does not exist in To or Subject field."} 0 도무지 어디가 잘못된지 모르겠네요... 줄바꿈은 전부 CRLF(\r\n)를 사용했습니다. localhost 환경에서 하고있는데 이것도 문제가되나요?
Mail 2019.12.20
POST https://apis.worksmobile.com/r/**API ID 부분**/mail/v2/sendMail HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36 Authorization: Bearer **AccessToken부분** consumerKey: **컨슈머키부분** Date: Tue, 17 Dec 2019 08:48:36 GMT Content-Type: multipart/mixed; boundary=--8d78319576b8eee; charset=UTF-8 Host: apis.worksmobile.com Content-Length: 746 Expect: 100-continue Connection: Keep-Alive ----8d78319576b8eee Content-Disposition: form-data; name="userName" jonghoon ----8d78319576b8eee Content-Disposition: form-data; name="to" ilms9012@gmail.com ----8d78319576b8eee Content-Disposition: form-data; name="cc" ----8d78319576b8eee Content-Disposition: form-data; name="bcc" ----8d78319576b8eee Content-Disposition: form-data; name="subject" this is subject ----8d78319576b8eee Content-Disposition: form-data; name="text" this is text ----8d78319576b8eee Content-Disposition: form-data; name="contentType" html ----8d78319576b8eee Content-Disposition: form-data; name="saveSentMail" true ----8d78319576b8eee Content-Disposition: form-data; name="sendSeparately" false ----8d78319576b8eee 이게 Request Raw Data 맞나요? api id,토큰,컨슈머키는 임의로 바꿔서올렸습니다. 아래 내용은 response raw입니다. HTTP/1.1 500 Internal Server Error Date: Wed, 18 Dec 2019 02:32:21 GMT Server: Apache Strict-Transport-Security: max-age=63072000; includeSubdomains; preload Referrer-Policy: unsafe-url Connection: close Transfer-Encoding: chunked Content-Type: application/json;charset=UTF-8 4c {"message":"Unknown error","domain":"common","code":"INTERNAL_SERVER_ERROR"} 0
Mail 2019.12.17
상세한 답변 감사합니다. 멀티파트와 boundar의 코드를 수정했습니다. 그런데 그이후.GetResponse()할때 http status code 500 {"message":"Unknown error","domain":"common","code":"INTERNAL_SERVER_ERROR"} 에러가 뜨는경우는 어떤경우인가요? WebException의 Status는 ProtocolError 입니다.
boundary를 해당 링크문서대로 "--임의의값--"으로 넣고 해도 같은결과가 나오는데요 string boundary = "gc0p4Jq0M2Yt08jU534c0p"; string content_Type = "multipart/mixed; boundary=--" + boundary + "--; charset=UTF-8"; request.ContentType = content_Type;이런식으로 셋했습니다. 혹시 샘플코드는없나요?
Mail 2019.12.16
예외처리에서 Response값 확인하면 위에올려주신 '{"code":"INVALID_PARAMETER","domain":"mail","message":"Data does not exist in To or Subject field."}' 이게 뜨는데요, 파라미터 전달에 문제가 있는건가요? authorization 코드나 accessToken 받을때 비슷한 방식으로했는데 제대로 전달 및 응답이 됐었거든요, 그런데 여기서는 왜 안되는지 혹시 예상되는 부분이 있을까요?
Mail 2019.12.12