-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Post method write data to CRM but give Exception when building response #450
Comments
Righto, can you tell me what the returned json is so I can figure out the deserialisation problem? |
Is Account your extension or part of base CRM? If an extension can you supply your odata metadata? |
It is part of the base Dynamics CRM
Yahoo Mail: Search, Organize, Conquer
On Wed, May 15, 2024 at 10:05 PM, Dave ***@***.***> wrote:
Is Account your extension or part of base CRM? If an extension can you supply your odata metadata?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Thanks. I've just read the specification which says that a post "MUST contain the resource created" (and thus can't return nothing which would give the null problem you saw) if response code is 201. What status code was returned?
|
The Response Code is a 204 |
ok. I got it to return back a 201 and the Account data from the POST. Just needed to add "requestHeader" to the line of code below. client.accounts().requestHeader("Prefer", "return=representation").post(account); Thanks for helping with this |
Is it possible to do these two things with this project? |
Nice, glad you have a workaround. I will address this though. The fact that this is a possibility means that I should return |
In short, you can do anything with this project using custom requests. NavigationProperties that have ContainsTarget="True" will be listed as settable properties in an Account builder so that single operation efficiency can happen. I don't support the Partner attribute currently which is what the create table row call relates to and frankly the ability to effectively contain those properties, enabling a single post call, is not apparent in the odata 4 specification so I assume that this is an out-of-spec offering by Microsoft and might be in their custom metadata annotations (no idea where to find them, have seen such a thing for Graph service only). So you can use a CustomRequest to do anything but you can get a mix by setting unmapped fields. Would be nice to be able to set UnmappedFields in the builder (I'll look at that sometime) but it is doable using the @Test
public void test() {
Account a = Account.builderAccount() //
.name("Sample Account") //
.build() //
.withUnmappedField( //
"primaryContactId", //
Contact.builderContact() //
.firstname("John") //
.lastname("Smith") //
.build()) //
.withUnmappedField("opportunity_customer_accounts", //
Lists.newArrayList( //
Maps //
.put("name", (Object) "Opportunity associated to Sample Account")
.put("Opportunity_Tasks", //
Lists.newArrayList( //
Maps.put("subject", "Task associated to opportunity").build()))
.build()));
System.out.println(Serializer.INSTANCE.serializePrettyPrint(a));
if (false) {
microsoft.dynamics.crm.container.System client = ...
client.accounts().post(a);
}
} Output is
The catch is that the create table row docs indicate a 204 response again. Might be able to give it that header and have it work, you could try. I'll look very shortly at returning |
|
I just found this library today. Sorry, if I there is a better place to post this question
I run this code
and it successfully writes data to Dynamics CRM, however, it returns the below message.
java.lang.IllegalArgumentException: argument "content" is null
at com.fasterxml.jackson.databind.ObjectMapper._assertNotNull(ObjectMapper.java:5054)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3813)
at com.github.davidmoten.odata.client.Serializer.deserialize(Serializer.java:96)
at com.github.davidmoten.odata.client.internal.RequestHelper.submitAny(RequestHelper.java:194)
at com.github.davidmoten.odata.client.internal.RequestHelper.postAny(RequestHelper.java:159)
at com.github.davidmoten.odata.client.internal.RequestHelper.post(RequestHelper.java:131)
at com.github.davidmoten.odata.client.CollectionPageEntityRequest.post(CollectionPageEntityRequest.java:60)
at com.github.davidmoten.odata.client.CollectionEntityRequestOptionsBuilder.post(CollectionEntityRequestOptionsBuilder.java:199)
at com.github.davidmoten.odata.client.CollectionPageEntityRequest.post(CollectionPageEntityRequest.java:97)
The issue is that in this code the "String text" variable is null.
How do I make it return data in the Response? Am I missing something in my method calls?
The text was updated successfully, but these errors were encountered: