2014-03-25 4 views
1

나는 eloqua와 함께 일하고있다.나머지 API로 Eloqua에 POST하는 방법?

aspx 웹 페이지에서 나머지 api를 사용하여 eloqua로 이메일을 작성해야한다. 그러나 404 Bad Request을 얻는다.

다음은 내가 시도한 POST 요청의 코드 샘플입니다.

string authenticateStr = eloquainstance + @"\" + username + ':' + password; 

byte[] bytesToEncode = Encoding.UTF8.GetBytes(authenticateStr); 

string encodedText = Convert.ToBase64String(bytesToEncode); 

string requrl = "/assets/email"; 

string requestBody = "<subject>Test subject</subject>" + 
         "<senderName>Ajai Test</senderName>" + 
         "<senderEmail>[email protected]</senderEmail>" + 
         "<emailGroupId>9</emailGroupId>" + 
         "<htmlContent>This is a test email templete created  trough rest api.This is for testing purpose only</htmlContent>"+ 
         "<type>Email</type>" + 
         "<name>Email By api</name>"; 


HttpWebRequest request = (HttpWebRequest)WebRequest.Create(baseurl + requrl); 
request.Headers.Add("Authorization", "Basic " + encodedText); 
request.Accept = "application/xml";//"application/x-www-form-urlencoded"; 
request.Method = "POST"; 
request.ContentType = "application/xml"; 
request.ContentLength = requestBody.Length; 

//write body to text 
byte[] body = System.Text.Encoding.UTF8.GetBytes(requestBody); 
Stream dataStream = request.GetRequestStream(); 
dataStream.Write(body, 0, requestBody.Length); 
dataStream.Close(); 

HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse(); 

제발 올바른 만약 내 코드에 뭔가 잘못.

아무도 eloqua 나머지 API를 사용하여 게시물을 시도해 볼 수 있습니까? 그렇다면 C#에서 eloqua로 POST 요청을하기 위해 샘플 코드를 공유 할 수 있습니다.

답변

0

당신이 가지고 있는지 확실하지이이 요청 이후 시간이 경과으로 아직 작업,하지만 당신은 eloqua의 topliners 사이트 사용에 대한 샘플의 전체 집합을 찾을 수 있습니다

http://topliners.eloqua.com/community/code_it/blog/2012/10/08/eloqua-rest-api--open-source-c-samples

를보고 코드는 당신이 HTML 본문

나는 또한 이메일 오브젝트를 표현하고 요청을 serialising하고 응답을 처리하는 프로세스를 단순화하기 위해 restsharp를 사용하는 클래스를 작성 고려할를 탈출해야 할 수 있습니다 생각합니다.

또한 피들러를 사용하여 테스트 요청을 실험 해보십시오.

관련 문제