How can i get the sharedmailbox mails from EWS api? - c#

I am able to get the sharedmailbox mail by this C# code but I want api for the same .Is EWS server provide so .
FolderId SharedMailbox = new FolderId(WellKnownFolderName.Inbox,"Shared#domain.com");
ItemView itemView = new ItemView(1000);
service.FindItems(SharedMailbox,itemView);
I see there is something which give me my mailbox details
https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/findconversation-operation
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP1" />
</soap:Header>
<soap:Body>
<m:FindConversation>
<m:IndexedPageItemView BasePoint="Beginning" MaxEntriesReturned="1" Offset="0"/>
<m:ParentFolderId>
<t:DistinguishedFolderId Id ="inbox"/>
</m:ParentFolderId>
</m:FindConversation>
</soap:Body>
</soap:Envelope>
I want same like for my shared mailbox mails.
Is there is any api same like this for shared mailbox mail?

You can use this. You can mention shared mailbox like this.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
</soap:Header>
<soap:Body>
<m:FindConversation>
<m:IndexedPageItemView MaxEntriesReturned="1" Offset="0" BasePoint="End" />
<m:ParentFolderId>
<t:DistinguishedFolderId Id="inbox" >
<t:Mailbox>
<t:EmailAddress>sharedmail#mail.com</t:EmailAddress>
</t:Mailbox>
</t:DistinguishedFolderId>
</m:ParentFolderId>
</m:FindConversation>
</soap:Body>
</soap:Envelope>

Related

c# send SOAP request with headers

I need to send an custom header mentioned below and get response from the proxy client. could some please share some basic sample code to achive the same.
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ses="http://xml.amadeus.com/2010/06/Session_v3">
<soap:Header>
<add:MessageID xmlns:add="http://www.w3.org/2005/08/addressing">0685482c-7f32-46b6-b27f-3149935b9307</add:MessageID>
<add:Action xmlns:add="http://www.w3.org/2005/08/addressing">http://webservices.amadeus.com/Hotel_MultiSingleAvailability_10.0</add:Action>
<add:To xmlns:add="http://www.w3.org/2005/08/addressing">https://noded5.test.webservices.amadeus.com/1ASIWPOC1A</add:To>
<link:TransactionFlowLink xmlns:link="http://wsdl.amadeus.com/2010/06/ws/Link_v1" />
<oas:Security xmlns:oas="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<oas:UsernameToken xmlns:oas1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" oas1:Id="UsernameToken-1">
<oas:Username></oas:Username>
<oas:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">RjJmUSsjczI=</oas:Nonce>
<oas:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">ZmJhZTdhY2E0YzdkYjIyODFkNDY2Y2RjZDYxN2MyZDlkYTE5NWJkYg==</oas:Password>
<oas1:Created>2022-09-08T18:27:59.86Z</oas1:Created>
</oas:UsernameToken>
</oas:Security>
<AMA_SecurityHostedUser xmlns="http://xml.amadeus.com/2010/06/Security_v1">
<UserID AgentDutyCode="SU" POS_Type="1" PseudoCityCode="" RequestorType="U" />
</AMA_SecurityHostedUser>
</soap:Header>
</soap:Envelope>

Exchange Soap Update notes contact?

I was unable to execute a Soap Exhange request to update contacts:PersonalNotes .
I have not found documentation on msdn: https://msdn.microsoft.com/en-us/library/office/ee693002(v=exchg.80).aspx
this is my soap code:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2016" />
<t:TimeZoneContext>
<t:TimeZoneDefinition Id="Eastern Standard Time" />
</t:TimeZoneContext>
</soap:Header>
<soap:Body>
<m:UpdateItem MessageDisposition="SaveOnly"
ConflictResolution="AlwaysOverwrite">
<m:ItemChanges>
<t:ItemChange>
<t:ItemId
Id="AAMkAD...QAAAz9hI5AAA=" ChangeKey="EQAAAB...QAAAz9rdN" />
<t:Updates>
<t:SetItemField>
<t:FieldURI FieldURI="contacts:Notes" />
<t:Contact>
<t:Notes>TEST N</t:Notes>
</t:Contact>
</t:SetItemField>
</t:Updates>
</t:ItemChange>
</m:ItemChanges>
</m:UpdateItem>
</soap:Body>
</soap:Envelope>
this the error displayed:
What is the soap code to write to edit the Contact PersonalNotes ?
The Notes field in a Contact is the Body Property of a Message so to update you need to update the body eg
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013_SP1" />
</soap:Header>
<soap:Body>
<m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOverwrite">
<m:ItemChanges>
<t:ItemChange>
<t:ItemId Id="AAMkADczN=" ChangeKey="EQAAABYAAAB1EEf9R" />
<t:Updates>
<t:SetItemField>
<t:FieldURI FieldURI="item:Body" />
<t:Contact>
<t:Body BodyType="Text">test text</t:Body>
</t:Contact>
</t:SetItemField>
</t:Updates>
</t:ItemChange>
</m:ItemChanges>
</m:UpdateItem>
</soap:Body>
</soap:Envelope>

missing prefix in soap request c# dynamic web request

I´m using the WsdlImporter to read a wsdl-file and create a dynamic web request. But if I create the request a prefix in my request is missing and the consuming web service can not handle with this request. How can I force, that the prefix will be set?
This is how the request should be:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:urn="urn:sap-com:document:sap:rfc:functions>
<soap:Body>
<urn:K23G_GET_COST_ELEMENTS>
<ID_BEKNZ xmlns="">S</ID_BEKNZ>
<ID_COLLECT_MESSAGES xmlns="">X</ID_COLLECT_MESSAGES>
<ID_GJAHR xmlns="">2016</ID_GJAHR>
<ID_KOKRS xmlns="">K001</ID_KOKRS>
<ID_VERSN xmlns="">000</ID_VERSN>
<ID_WRTTP xmlns="">04</ID_WRTTP>
<ET_MESG xmlns="">
<item />
</ET_MESG>
<ET_RESULTS xmlns="">
<item />
</ET_RESULTS>
<IT_COSEL_KSTAR xmlns="">
<item />
</IT_COSEL_KSTAR>
<IT_COSEL_OBJ xmlns="">
<item />
</IT_COSEL_OBJ>
</urn:K23G_GET_COST_ELEMENTS>
</soap:Body>
</soap:Envelope>
An this is how the request looks like:
The urn before K23G_GET_COST_ELEMENTS is missing
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<K23G_GET_COST_ELEMENTS xmlns:urn="urn:sap-com:document:sap:rfc:functions>
<ID_BEKNZ xmlns="">S</ID_BEKNZ>
<ID_COLLECT_MESSAGES xmlns="">X</ID_COLLECT_MESSAGES>
<ID_GJAHR xmlns="">2016</ID_GJAHR>
<ID_KOKRS xmlns="">K001</ID_KOKRS>
<ID_VERSN xmlns="">000</ID_VERSN>
<ID_WRTTP xmlns="">04</ID_WRTTP>
<ET_MESG xmlns="">
<item />
</ET_MESG>
<ET_RESULTS xmlns="">
<item />
</ET_RESULTS>
<IT_COSEL_KSTAR xmlns="">
<item />
</IT_COSEL_KSTAR>
<IT_COSEL_OBJ xmlns="">
<item />
</IT_COSEL_OBJ>
</urn:K23G_GET_COST_ELEMENTS>
</soap:Body>
</soap:Envelope>
Somebody there who can help me?
Thank you

SOAP fault message

I have to send a SOAP fault message over HTTP to another web service if something goes wrong with a server, so I have this code:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<Response status="1">
<Description>DESC</Description>
<Errors>
<Error>500</Error>
</Errors>
</Response>
</soapenv:Body>
</soapenv:Envelope>
Is this a properly formatted SOAP fault message?
Is this a properly formatted SOAP fault message?
No it isn't. It should look something like this:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>...</faultcode>
<faultstring>...</faultstring>
<detail>...</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
The SOAP specification specifies what a fault is. Yours looks like an error result object of some sort which has some disadvantages as explained here for example.
Your WS framework should properly generate faults if you throw exceptions. If you are not using a framework but building the fault in some other way, then it must look like in my example above or it can't be called a SOAP fault.
Hey Bogdan I wrote this code and works like a charm!
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<soap:Fault>
<faultcode>500</faultcode>
<faultstring>SERVER ERROR</faultstring>
<detail>
<Response_status>1</Response_status>
<Description>DESCRIPTION</Description>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
But another question how to send a SOAP success message with a http code 200 an also I have to have some additional parameters in the message, this is a part of it
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<Response_status>0</Response_status>
<Description>SUCCESS</Description>
</soap:Body>
</soap:Envelope>
So with this also I have to send code 200, how to write that can I write it like this
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<soap:Fault>
<faultcode>200</faultcode>
<faultstring>OK</faultstring>
<detail>
<Response_status>0</Response_status>
<Description>SUCCESS</Description>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>

AdWords API : client list for non MCC account

I want to get a list of AdWords clients assigned to authenticated account (i use OAuth).
First attempt was to use ServicedAccountService and this XML request
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<RequestHeader xmlns="https://adwords.google.com/api/adwords/mcm/v201109">
<developerToken xmlns="https://adwords.google.com/api/adwords/mcm/v201109">[[DEV_TOKEN]]</developerToken>
</RequestHeader>
</soap:Header>
<soap:Body>
<get xmlns="https://adwords.google.com/api/adwords/mcm/v201109">
<selector>
<enablePaging>false</enablePaging>
</selector>
</get>
</soap:Body>
</soap:Envelope>
But it works only for MCC accounts. For regular google account i got empty dataset
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<ResponseHeader xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109" xmlns="https://adwords.google.com/api/adwords/mcm/v201109">
<ns2:requestId>0004bc71cee633d00aecb0aa000060ca</ns2:requestId>
<ns2:serviceName>ServicedAccountService</ns2:serviceName>
<ns2:methodName>get</ns2:methodName>
<ns2:operations>0</ns2:operations>
<ns2:responseTime>230</ns2:responseTime>
<ns2:units>0</ns2:units>
</ResponseHeader>
</soap:Header>
<soap:Body>
<getResponse xmlns="https://adwords.google.com/api/adwords/mcm/v201109" xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109">
<rval>
<accounts>
<customerId>0</customerId>
<canManageClients>false</canManageClients>
</accounts>
</rval>
</getResponse>
</soap:Body>
</soap:Envelope>
I googled a lot, and finally found that i can use other XML (InfoService) for both MCC and non MCC accounts.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<RequestHeader xmlns="https://adwords.google.com/api/adwords/info/v201109">
<developerToken xmlns="https://adwords.google.com/api/adwords/cm/v201109">[[DEV_TOKEN]]</developerToken>
</RequestHeader>
</soap:Header>
<soap:Body>
<get xmlns="https://adwords.google.com/api/adwords/info/v201109">
<selector>
<dateRange>
<min xmlns="https://adwords.google.com/api/adwords/cm/v201109">[[START_DATE]]</min>
<max xmlns="https://adwords.google.com/api/adwords/cm/v201109">[[END_DATE]]</max>
</dateRange>
<includeSubAccounts>true</includeSubAccounts>
<apiUsageType>UNIT_COUNT_FOR_CLIENTS</apiUsageType>
</selector>
</get>
</soap:Body>
</soap:Envelope>
But data returned is incorrect - not all accounts are listed. Or no data returned at all.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<ResponseHeader xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109" xmlns="https://adwords.google.com/api/adwords/info/v201109">
<ns2:requestId>0004bc7121a910e80a97030d000051e7</ns2:requestId>
<ns2:serviceName>InfoService</ns2:serviceName>
<ns2:methodName>get</ns2:methodName>
<ns2:operations>1</ns2:operations>
<ns2:responseTime>1206</ns2:responseTime>
<ns2:units>1</ns2:units>
</ResponseHeader>
</soap:Header>
<soap:Body>
<getResponse xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109" xmlns="https://adwords.google.com/api/adwords/info/v201109">
<rval>
<cost>0</cost>
</rval>
</getResponse>
</soap:Body>
</soap:Envelope>
Is there any other way to get client list for AdWords account? Thanks a lot.
I've also encountered this problem, and can confirm that it's not the correct behaviour of the ServicedAccountService; it's a "known issue that will be resolved in future": If you link your basic account to an MCC, then you can authenticate with the basic account and use the ServicedAccountService to obtain the account details, but if the account isn't linked then you'll get this problem.
If you just want to obtain the customer id for an account, you can also use the InfoService, which doesn't suffer from the same issue.

Categories

Resources