2013-05-07 102 views
4

基本上我想要做的是創建工作流程(sharepoint 2013o365),它將發送電子郵件到文檔上傳管理器。Sharepoint 2013工作流程 - HttpSend操作無法反序列化JSON數據

爲此,我在VS 2012中創建了自定義活動,該活動應返回上傳者配置文件,我想從中提取管理員登錄名。

我使用該HttpSend行動和以下REST服務:

uri + "_api/SP.UserProfiles.PeopleManager/GetPropertiesFor([email protected])[email protected]='" + Login + "'" 

反應是好的 - 我用小提琴手攔截它,我可以與任何JSON parser(包括bulit-解析它在進入小提琴手)

{"d":{"__metadata":   {"id":"http://sp13dev/sites/dev/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor([email protected])","uri":"http://sp13dev/sites/dev/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor([email protected])","type":"SP.UserProfiles.PersonProperties"},"AccountName":"MVO\\mvogelsi","DirectReports":{"results":[]},"DisplayName":"Marcin Vogelsinger","Email":null,"ExtendedManagers":{"results":["MVO\\rmakowsk"]},"ExtendedReports":{"results":["MVO\\mvogelsi"]},"IsFollowed":false,"LatestPost":null,"Peers":{"results":["MVO\\tbiolo"]},"PersonalUrl":"http://sp13dev/my/Person.aspx?accountname=MVO%5Cmvogelsi","PictureUrl":null,"Title":null,"UserProfileProperties": {"results":[{"__metadata":{"type":"SP.KeyValue"},"Key":"UserProfile_GUID","Value":"b3d09b4d-0d7e-45be-a3d9-b9f23a972e9c","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SID","Value":"S-1-5-21-28665521-4166225307-422210891-1000","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"ADGuid","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"AccountName","Value":"MVO\\mvogelsi","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"FirstName","Value":"Marcin","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-PhoneticFirstName","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"LastName","Value":"Vogelsinger","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-PhoneticLastName","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"PreferredName","Value":"Marcin Vogelsinger","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-PhoneticDisplayName","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"WorkPhone","Value":"888265520","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"Department","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"Title","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-JobTitle","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-Department","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"Manager","Value":"MVO\\rmakowsk","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"AboutMe","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"PersonalSpace","Value":"SPSSITEERROR","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"PictureURL","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"UserName","Value":"mvogelsi","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"QuickLinks","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"WebSite","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"PublicSiteRedirect","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-Dotted-line","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-Peers","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-Responsibility","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-SipAddress","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-MySiteUpgrade","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-ProxyAddresses","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-HireDate","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-DisplayOrder","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-ClaimID","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-ClaimProviderID","Value":"Windows","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-ClaimProviderType","Value":"Windows","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-SavedAccountName","Value":"MVO\\mvogelsi","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-SavedSID","Value":"System.Byte[]","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-ResourceSID","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-ResourceAccountName","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-ObjectExists","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-MasterAccountName","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-UserPrincipalName","Value":"[email protected]","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-PersonalSiteCapabilities","Value":"0","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-O15FirstRunExperience","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-PersonalSiteInstantiationState","Value":"8197","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-DistinguishedName","Value":"CN=Marcin Vogelsinger,CN=Users,DC=mvo,DC=dom","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-SourceObjectDN","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-FeedIdentifier","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"WorkEmail","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"CellPhone","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"Fax","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"HomePhone","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"Office","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-Location","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"Assistant","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-PastProjects","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-Skills","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-School","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-Birthday","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-StatusNotes","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-Interests","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-HashTags","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-EmailOptin","Value":"","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-PrivacyPeople","Value":"False","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-PrivacyActivity","Value":"0","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"SPS-TimeZone","Value":"","ValueType":"Edm.String"}]},"UserUrl":"http://sp13dev:80/my/Person.aspx?accountname=MVO%5Cmvogelsi"}} 

我使用SP設計師2013創建簡單的工作流程中這一習俗活動,並部署在我的開發環境。 但是,試圖啓動工作流時,它就會被取消,並出現以下錯誤:

Details: System.IO.InvalidDataException: Unable to deserialize HTTP response content. Expected ContentType : 'application/json', 'text/plain' or 'text/html', Received ContentType : 'application/json'. Content (truncated) : '{"d":{"__metadata":{"id":"http://sp13dev/sites/dev/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor([email protected])","uri":"http://sp13dev [here goes the rest of JSON which is already available above] 

因爲它是O365我需要去聲明方式。

有沒有人遇到過這樣的問題?

回答

0

我已經面臨過類似的問題,跨越博客裏面幫我固定在同一

的原因問題來了,通過從SharePoint REST 是在XML和SharePoint Designer工作流默認響應無法解析xml 並需要JSON響應。要解決此問題,我們需要通過Accept 和Content-Type作爲application/json; odata = verbose來請求標頭。 這樣我們將得到JSON響應。

https://prasadpathak.wordpress.com/tag/expected-content-type-applicationjson/

嘗試在上述博客中提到的步驟。