-
Notifications
You must be signed in to change notification settings - Fork 30
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
Exception in deserilization of post message #1487
Comments
Hi @chandraarora Can you confirm in which language your client application is please? |
Hi
It's in typescript
|
Thank you for the additional information. Can you share the code snippet where you're initializing the request? Also why are you sharing a dotnet stack trace in the initial post? |
Stack strace trace message is from server side and unable to deserialize in controller. input - >{ "docName": "test.docx", "docContent": "asdf" } output -> "\u001f�\b\u0000\u0000\u0000\u0000\u0000\u0000\n�VJ�Ov��+I�+Q�RJ,NIS�\u0001��%�*Y)��\u0016���'W(�\u0002\u0000F�Ô+\u0000\u0000\u0000", Code sample import { ApiKeyAuthenticationProvider, ApiKeyLocation, RequestConfiguration } from "@microsoft/kiota-abstractions";
import { FetchRequestAdapter } from "@microsoft/kiota-http-fetchlibrary";
import { createPdf4meClient } from "../src/client/pdf4meClient.js";
import { ConvertToPdfPostRequestBody, ConvertToPdfPostRequestBody_document } from "../src/client/api/v2/convertToPdf/index.js";
import { WebhookSubscribePostRequestBody} from "../src/client/api/v2/webhookSubscribe/index.js";
async function convertToPdf(): Promise<void> {
try {
// API requires no authentication, so use the anonymous
// authentication provider
const authProvider = new ApiKeyAuthenticationProvider("Basic ****", "Authorization", ApiKeyLocation.Header);
// Create request adapter using the fetch-based implementation
const adapter = new FetchRequestAdapter(authProvider);
adapter.baseUrl= "http://localhost:5000";
// Create the API client
const client = createPdf4meClient(adapter);
const document : ConvertToPdfPostRequestBody_document =
{
name: "test.png"
}
const body : ConvertToPdfPostRequestBody =
{
docContent : "base64 of png",
document : document
}
const postReq = client.api.v2.convertToPdf.post(body);
}catch (err) {
console.log(err);
}
}
convertToPdf() |
Thank you for the additional information. When setting the doc content, are you base64 encoding the byte array? The client is already doing that for you. Let us know if you have any additional comments or questions. |
Thank you, we will try and give you a feedback
|
Thank you for the additional information. If you try generating a csharp client instead, what's the type of the property? |
That is also string and I send base64 which works.
|
Thank you for the additional information. In TypeScript, here is the serialization code that's generated. export function serializeConvertToPdfPostRequestBody(writer: SerializationWriter, convertToPdfPostRequestBody: Partial<ConvertToPdfPostRequestBody> | undefined | null = {}) : void {
if (convertToPdfPostRequestBody) {
writer.writeStringValue("docContent", convertToPdfPostRequestBody.docContent);
writer.writeObjectValue<ConvertToPdfPostRequestBody_document>("document", convertToPdfPostRequestBody.document, serializeConvertToPdfPostRequestBody_document);
writer.writeAdditionalData(convertToPdfPostRequestBody.additionalData);
}
} And the equivalent in CSharp public virtual void Serialize(ISerializationWriter writer)
{
_ = writer ?? throw new ArgumentNullException(nameof(writer));
writer.WriteStringValue("docContent", DocContent);
writer.WriteObjectValue<global::Graphdotnetv4.Api.V2.ConvertToPdf.ConvertToPdfPostRequestBody_document>("document", Document);
writer.WriteAdditionalData(AdditionalData);
} As you can see, both languages are calling "writeStringValue" which in JSON ends up writing a JSON string without further transformations being applied. I encourage you to compare the application code between the dotnet and javascript applications to understand whether the pre-processing you're applying results in different strings being set on the object for the same initial document. |
Hi
We are getting the error when we try a method, please see the definition below. We are sending base64 string for byte[] and it is getting encoded again?
Could you please suggest what is wrong here?
Thanks
Chandra
System.Text.DecoderFallbackException: Unable to translate bytes [8B] at index 1 from specified code page to Unicode.
at System.Text.DecoderExceptionFallbackBuffer.Throw(Byte[] bytesUnknown, Int32 index)
at System.Text.DecoderExceptionFallbackBuffer.Fallback(Byte[] bytesUnknown, Int32 index)
at System.Text.Encoding.GetCharsWithFallback(ReadOnlySpan
1 bytes, Int32 originalBytesLength, Span
1 chars, Int32 originalCharsLength, DecoderNLS decoder)at System.Text.UTF8Encoding.GetCharsWithFallback(ReadOnlySpan
1 bytes, Int32 originalBytesLength, Span
1 chars, Int32 originalCharsLength, DecoderNLS decoder)at System.Text.Encoding.GetCharsWithFallback(Byte* pOriginalBytes, Int32 originalByteCount, Char* pOriginalChars, Int32 originalCharCount, Int32 bytesConsumedSoFar, Int32 charsWrittenSoFar, DecoderNLS decoder)
at System.Text.Encoding.GetChars(Byte* pBytes, Int32 byteCount, Char* pChars, Int32 charCount, DecoderNLS decoder)
at System.Text.DecoderNLS.GetChars(Byte* bytes, Int32 byteCount, Char* chars, Int32 charCount, Boolean flush)
at System.Text.DecoderNLS.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex, Boolean flush)
at System.Text.DecoderNLS.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex)
at Microsoft.AspNetCore.WebUtilities.HttpRequestStreamReader.ReadIntoBuffer()
Open API method
The text was updated successfully, but these errors were encountered: